Commit 6ab1e799 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix_jenkins_auth' into 'master'

Fix jenkins auth

WebHooks currently support basic auth in the webhook URL - `http://user:pass@example.com`. With the Jenkins CI service the webhook is fired correctly when the project URL is in this format. However, the build status was unable to poll because auth was not used correctly.

This merge requests implements the basic auth strategy much the same as the web hook does. See https://gitlab.com/subscribers/gitlab-ee/blob/master/app/models/web_hook.rb#L34 for reference.
parents 95cfe768 f1e38963
...@@ -60,7 +60,18 @@ class JenkinsService < CiService ...@@ -60,7 +60,18 @@ class JenkinsService < CiService
end end
def commit_status sha def commit_status sha
parsed_url = URI.parse(build_page(sha))
if parsed_url.userinfo.blank?
response = HTTParty.get(build_page(sha), verify: false) response = HTTParty.get(build_page(sha), verify: false)
else
get_url = build_page(sha).gsub("#{parsed_url.userinfo}@", "")
auth = {
username: URI.decode(parsed_url.user),
password: URI.decode(parsed_url.password),
}
response = HTTParty.get(get_url, verify: false, basic_auth: auth)
end
if response.code == 200 if response.code == 200
if response.include?('alt="Success"') if response.include?('alt="Success"')
......
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