Commit 5ace25cf authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ee_fix_jenkins_status_check' into 'master'

EE - fix jenkins status check

When using Jenkins CI via the `JenkinsService` class, GitLab queries Jenkins for build status of a specific git commit shasum. This check however is done in an error prone way and fails for Jenkins jobs with multiple modules. Please note the three bubbles at the bottom of this screenshot: http://i.imgur.com/cptQdOG.png

This MR changes the checking code to make use of a HTML parser and selects the element of interest via its xpath. It was manually tested against Jenkins version 1.554 (LTS release as of today) with both maven and freestyle type jobs.
parents 26d862fa 9089a5d1
...@@ -72,11 +72,12 @@ class JenkinsService < CiService ...@@ -72,11 +72,12 @@ class JenkinsService < CiService
end end
if response.code == 200 if response.code == 200
if response.include?('alt="Success"') status = Nokogiri.parse(response).xpath('//img[@class="build-caption-status-icon"]').first.attributes['alt'].value
if status.include?('Success')
'success' 'success'
elsif response.include?('alt="Failed"') || response.include?('alt="Aborted"') elsif status.include?('Failed') || status.include?('Aborted')
'failed' 'failed'
elsif response.include?('alt="In progress"') elsif status.include?('In progress')
'running' 'running'
else else
'pending' 'pending'
......
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