From 9089a5d15bf7bb59935787954fccaa8efefbc1d7 Mon Sep 17 00:00:00 2001 From: Marvin Frick Date: Mon, 7 Jul 2014 14:22:18 +0200 Subject: [PATCH] changes the check for Jenkins_CI status Instead of plaintext http response body reading, this service now checks for a value at a specified xpath in the document. --- app/models/project_services/jenkins_service.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/project_services/jenkins_service.rb b/app/models/project_services/jenkins_service.rb index 44b34a405b..9f6120b6fe 100644 --- a/app/models/project_services/jenkins_service.rb +++ b/app/models/project_services/jenkins_service.rb @@ -74,11 +74,12 @@ class JenkinsService < CiService end 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' - elsif response.include?('alt="Failed"') || response.include?('alt="Aborted"') + elsif status.include?('Failed') || status.include?('Aborted') 'failed' - elsif response.include?('alt="In progress"') + elsif status.include?('In progress') 'running' else 'pending'