Commit f0c5977a authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '3335-error-reading-commit-status-in-jenkinsdeprecatedservice' into 'master'

Resolve "Error reading commit status in JenkinsDeprecatedService"

Closes #3335

See merge request gitlab-org/gitlab-ee!3363
parents e3f7892e 2c2693e6
......@@ -14,7 +14,7 @@ class JenkinsDeprecatedService < CiService
def compose_service_hook
hook = service_hook || build_service_hook
jenkins_url = project_url.sub(/job\/.*/, '')
hook.url = jenkins_url + "/gitlab/build_now"
hook.url = jenkins_url + "gitlab/build_now"
hook.save
end
......@@ -101,7 +101,13 @@ class JenkinsDeprecatedService < CiService
if response.code == 200
# 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
begin
src = Nokogiri.parse(response).css('img.build-caption-status-icon,.build-caption>img').first.attributes['src'].value
rescue NoMethodError => ex
Raven.capture_exception(ex, extra: { 'response' => response })
return :error
end
if src =~ /blue\.png$/ || (src =~ /yellow\.png/ && pass_unstable?)
'success'
elsif src =~ /(red|aborted|yellow)\.png$/
......
......@@ -11,10 +11,11 @@ describe JenkinsDeprecatedService, use_clean_rails_memory_store_caching: true do
describe 'commits methods' do
def status_body_for_icon(state)
<<eos
<h1 class="build-caption page-headline"><img style="width: 48px; height: 48px; " alt="Success" class="icon-#{state} icon-xlg" src="/static/855d7c3c/images/48x48/#{state}" tooltip="Success" title="Success">
Build #188
(Oct 15, 2014 9:45:21 PM)
</h1>
<h1 class="build-caption page-headline">
<img src="/static/8b0a9b52/images/48x48/#{state}" alt="Success" tooltip="Success" style="width: 48px; height: 48px; " class="icon-#{state} icon-xlg" />
Build #188
(Oct 15, 2014 9:45:21 PM)
</h1>
eos
end
......@@ -49,6 +50,13 @@ eos
expect(@service.calculate_reactive_cache('2ab7834c', 'master')).to eq(commit_status: 'success')
end
end
context 'with bad response' do
it 'has a commit_status of error' do
stub_request(:get, "http://jenkins.gitlab.org/job/2/scm/bySHA1/2ab7834c").to_return(status: 200, body: '<h1>404</h1>', headers: {})
expect(@service.calculate_reactive_cache('2ab7834c', 'master')).to eq(commit_status: :error)
end
end
end
describe '#commit_status' do
......
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