BigW Consortium Gitlab

Commit e5fe14b2 by Valery Sizov

Link to CI with ref

parent 478f92d2
...@@ -13,6 +13,7 @@ v 7.10.0 (unreleased) ...@@ -13,6 +13,7 @@ v 7.10.0 (unreleased)
- Identical look of selectboxes in UI - Identical look of selectboxes in UI
- Move "Import existing repository by URL" option to button. - Move "Import existing repository by URL" option to button.
- Improve error message when save profile has error. - Improve error message when save profile has error.
- Passing the name of pushed ref to CI service (requires GitLab CI 7.9+)
v 7.9.0 (unreleased) v 7.9.0 (unreleased)
- Add HipChat integration documentation (Stan Hu) - Add HipChat integration documentation (Stan Hu)
......
...@@ -160,10 +160,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -160,10 +160,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def ci_status def ci_status
ci_service = @merge_request.source_project.ci_service ci_service = @merge_request.source_project.ci_service
status = ci_service.commit_status(merge_request.last_commit.sha) status = ci_service.commit_status(merge_request.last_commit.sha, merge_request.source_branch)
if ci_service.respond_to?(:commit_coverage) if ci_service.respond_to?(:commit_coverage)
coverage = ci_service.commit_coverage(merge_request.last_commit.sha) coverage = ci_service.commit_coverage(merge_request.last_commit.sha, merge_request.source_branch)
end end
response = { response = {
......
...@@ -35,7 +35,7 @@ module MergeRequestsHelper ...@@ -35,7 +35,7 @@ module MergeRequestsHelper
end end
def ci_build_details_path(merge_request) def ci_build_details_path(merge_request)
merge_request.source_project.ci_service.build_page(merge_request.last_commit.sha) merge_request.source_project.ci_service.build_page(merge_request.last_commit.sha, merge_request.source_branch)
end end
def merge_path_description(merge_request, separator) def merge_path_description(merge_request, separator)
......
...@@ -93,7 +93,7 @@ class BambooService < CiService ...@@ -93,7 +93,7 @@ class BambooService < CiService
end end
end end
def build_page(sha) def build_page(sha, ref)
build_info(sha) if @response.nil? || !@response.code build_info(sha) if @response.nil? || !@response.code
if @response.code != 200 || @response['results']['results']['size'] == '0' if @response.code != 200 || @response['results']['results']['size'] == '0'
...@@ -106,7 +106,7 @@ class BambooService < CiService ...@@ -106,7 +106,7 @@ class BambooService < CiService
end end
end end
def commit_status(sha) def commit_status(sha, ref)
build_info(sha) if @response.nil? || !@response.code build_info(sha) if @response.nil? || !@response.code
return :error unless @response.code == 200 || @response.code == 404 return :error unless @response.code == 200 || @response.code == 404
......
...@@ -48,7 +48,7 @@ class BuildboxService < CiService ...@@ -48,7 +48,7 @@ class BuildboxService < CiService
service_hook.execute(data) service_hook.execute(data)
end end
def commit_status(sha) def commit_status(sha, ref)
response = HTTParty.get(commit_status_path(sha), verify: false) response = HTTParty.get(commit_status_path(sha), verify: false)
if response.code == 200 && response['status'] if response.code == 200 && response['status']
...@@ -62,7 +62,7 @@ class BuildboxService < CiService ...@@ -62,7 +62,7 @@ class BuildboxService < CiService
"#{buildbox_endpoint('gitlab')}/status/#{status_token}.json?commit=#{sha}" "#{buildbox_endpoint('gitlab')}/status/#{status_token}.json?commit=#{sha}"
end end
def build_page(sha) def build_page(sha, ref)
"#{project_url}/builds?commit=#{sha}" "#{project_url}/builds?commit=#{sha}"
end end
......
...@@ -34,7 +34,7 @@ class CiService < Service ...@@ -34,7 +34,7 @@ class CiService < Service
# Ex. # Ex.
# http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c # http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c
# #
def build_page(sha) def build_page(sha, ref)
# implement inside child # implement inside child
end end
...@@ -51,7 +51,7 @@ class CiService < Service ...@@ -51,7 +51,7 @@ class CiService < Service
# # => 'running' # # => 'running'
# #
# #
def commit_status(sha) def commit_status(sha, ref)
# implement inside child # implement inside child
end end
end end
...@@ -40,17 +40,17 @@ class GitlabCiService < CiService ...@@ -40,17 +40,17 @@ class GitlabCiService < CiService
service_hook.execute(data) service_hook.execute(data)
end end
def commit_status_path(sha) def commit_status_path(sha, ref)
project_url + "/commits/#{sha}/status.json?token=#{token}" project_url + "/refs/#{ref}/commits/#{sha}/status.json?token=#{token}"
end end
def get_ci_build(sha) def get_ci_build(sha, ref)
@ci_builds ||= {} @ci_builds ||= {}
@ci_builds[sha] ||= HTTParty.get(commit_status_path(sha), verify: false) @ci_builds[sha] ||= HTTParty.get(commit_status_path(sha, ref), verify: false)
end end
def commit_status(sha) def commit_status(sha, ref)
response = get_ci_build(sha) response = get_ci_build(sha, ref)
if response.code == 200 and response["status"] if response.code == 200 and response["status"]
response["status"] response["status"]
...@@ -59,16 +59,16 @@ class GitlabCiService < CiService ...@@ -59,16 +59,16 @@ class GitlabCiService < CiService
end end
end end
def commit_coverage(sha) def commit_coverage(sha, ref)
response = get_ci_build(sha) response = get_ci_build(sha, ref)
if response.code == 200 and response["coverage"] if response.code == 200 and response["coverage"]
response["coverage"] response["coverage"]
end end
end end
def build_page(sha) def build_page(sha, ref)
project_url + "/commits/#{sha}" project_url + "/refs/#{ref}/commits/#{sha}"
end end
def builds_path def builds_path
......
...@@ -88,7 +88,7 @@ class TeamcityService < CiService ...@@ -88,7 +88,7 @@ class TeamcityService < CiService
@response = HTTParty.get("#{url}", verify: false, basic_auth: auth) @response = HTTParty.get("#{url}", verify: false, basic_auth: auth)
end end
def build_page(sha) def build_page(sha, ref)
build_info(sha) if @response.nil? || !@response.code build_info(sha) if @response.nil? || !@response.code
if @response.code != 200 if @response.code != 200
...@@ -103,7 +103,7 @@ class TeamcityService < CiService ...@@ -103,7 +103,7 @@ class TeamcityService < CiService
end end
end end
def commit_status(sha) def commit_status(sha, ref)
build_info(sha) if @response.nil? || !@response.code build_info(sha) if @response.nil? || !@response.code
return :error unless @response.code == 200 || @response.code == 404 return :error unless @response.code == 200 || @response.code == 404
......
...@@ -59,7 +59,7 @@ describe BuildboxService do ...@@ -59,7 +59,7 @@ describe BuildboxService do
describe :build_page do describe :build_page do
it 'returns the correct build page' do it 'returns the correct build page' do
expect(@service.build_page('2ab7834c')).to eq( expect(@service.build_page('2ab7834c', nil)).to eq(
'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c' 'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c'
) )
end end
......
...@@ -39,11 +39,11 @@ describe GitlabCiService do ...@@ -39,11 +39,11 @@ describe GitlabCiService do
end end
describe :commit_status_path do describe :commit_status_path do
it { expect(@service.commit_status_path("2ab7834c")).to eq("http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret")} it { expect(@service.commit_status_path("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c/status.json?token=verySecret")}
end end
describe :build_page do describe :build_page do
it { expect(@service.build_page("2ab7834c")).to eq("http://ci.gitlab.org/projects/2/commits/2ab7834c")} it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c")}
end end
end 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