Commit de96d399 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'jenkins_improve_parser' into 'master'

Jenkins: improved parser

Original issue - https://dev.gitlab.org/gitlab/gitlabhq/issues/1582

There were two problems:
1. Jenkins has changed html a bit
2. All the attributes of image indicator will be translated if locale is changed. So I had to parse path to image.

Now Jenkins service parses correctly both new and old status page. Also it does not matter what locale is set. Basically Jenkins look at the "Accept-Language" header from your browser for locale determining. So we could not take localisation into account at all. But there are ways to change this behaviour and just for sure I decided to implement localisation-independent way.

See merge request !234
parents 313bee58 b692a439
......@@ -69,12 +69,13 @@ class JenkinsService < CiService
end
if response.code == 200
status = Nokogiri.parse(response).xpath('//img[@class="build-caption-status-icon"]').first.attributes['alt'].value
if status.include?('Success')
# img.build-caption-status-icon for old jenkins version
src = Nokogiri.parse(response).css('img.build-caption-status-icon,.build-caption>img').first.attributes['src'].value
if src =~ /blue\.png$/
'success'
elsif status.include?('Failed') || status.include?('Aborted')
elsif src =~ /(red\.png|aborted\.png)$/
'failed'
elsif status.include?('In progress')
elsif src =~ /anime\.gif$/
'running'
else
'pending'
......
......@@ -21,10 +21,6 @@
.bs-callout
= @service.help
- if @service.help.present?
.bs-callout
= @service.help
.form-group
= f.label :active, "Active", class: "control-label"
.col-sm-10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment