Commit 2178647a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ci_status_handle_automatic_branch_jobs_in_jenkins' into 'master'

Adding in ability to check status of automatic branch jobs in jenkins

The current documentation for integrating Jenkins and Gitlab EE indicates that the Gitlab Hook Plugin should be used.  When you use that plugin you can set up Jenkins to automatically create new jobs for the branches used in merge requests.  The CI Status check for Jenkins does not currently handle those automatic jobs.  The result of this is shows an error checking the status on all Merge Requests.  This merge request is a small change to the jenkins_service to utilize the ref param being passed in and appending the branch name if not master to the project url which will allow the status checks to succeed.

See merge request !9
parents 23a8fc6b d02b139c
......@@ -34,9 +34,10 @@ v 7.12.0
- Fix error when viewing merge request with a commit that includes "Closes #<issue id>".
- Enhance LDAP group synchronization to check also for member attributes that only contain "uid=<username>"
- Enhance LDAP group synchronization to check also for submember attributes
- Prevent LDAP group sync from removing a group's last owner
- Prevent LDAP group sync from removing a group's last owner
- Add Git hook to validate maximum file size.
- Project setting: approve merge request by N users before accept
- Support automatic branch jobs created by Jenkins in CI Status
v 7.11.4
- no changes specific to EE
......
......@@ -51,16 +51,17 @@ class JenkinsService < CiService
end
def build_page(sha, ref = nil)
project_url + "/scm/bySHA1/#{sha}"
base_url = ref.nil? || ref == 'master' ? project_url : "#{project_url}_#{ref}"
base_url + "/scm/bySHA1/#{sha}"
end
def commit_status(sha, ref = nil)
parsed_url = URI.parse(build_page(sha))
parsed_url = URI.parse(build_page(sha, ref))
if parsed_url.userinfo.blank?
response = HTTParty.get(build_page(sha), verify: false)
response = HTTParty.get(build_page(sha, ref), verify: false)
else
get_url = build_page(sha).gsub("#{parsed_url.userinfo}@", "")
get_url = build_page(sha, ref).gsub("#{parsed_url.userinfo}@", "")
auth = {
username: URI.decode(parsed_url.user),
password: URI.decode(parsed_url.password),
......
......@@ -51,5 +51,9 @@ eos
describe :build_page do
it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c") }
end
describe :build_page_with_branch do
it { expect(@service.build_page("2ab7834c", 'test_branch')).to eq("http://jenkins.gitlab.org/projects/2_test_branch/scm/bySHA1/2ab7834c") }
end
end
end
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