BigW Consortium Gitlab

Commit e5fe14b2 by Valery Sizov

Link to CI with ref

parent 478f92d2
......@@ -13,6 +13,7 @@ v 7.10.0 (unreleased)
- Identical look of selectboxes in UI
- Move "Import existing repository by URL" option to button.
- 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)
- Add HipChat integration documentation (Stan Hu)
......
......@@ -160,10 +160,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def ci_status
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)
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
response = {
......
......@@ -35,7 +35,7 @@ module MergeRequestsHelper
end
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
def merge_path_description(merge_request, separator)
......
......@@ -93,7 +93,7 @@ class BambooService < CiService
end
end
def build_page(sha)
def build_page(sha, ref)
build_info(sha) if @response.nil? || !@response.code
if @response.code != 200 || @response['results']['results']['size'] == '0'
......@@ -106,7 +106,7 @@ class BambooService < CiService
end
end
def commit_status(sha)
def commit_status(sha, ref)
build_info(sha) if @response.nil? || !@response.code
return :error unless @response.code == 200 || @response.code == 404
......
......@@ -48,7 +48,7 @@ class BuildboxService < CiService
service_hook.execute(data)
end
def commit_status(sha)
def commit_status(sha, ref)
response = HTTParty.get(commit_status_path(sha), verify: false)
if response.code == 200 && response['status']
......@@ -62,7 +62,7 @@ class BuildboxService < CiService
"#{buildbox_endpoint('gitlab')}/status/#{status_token}.json?commit=#{sha}"
end
def build_page(sha)
def build_page(sha, ref)
"#{project_url}/builds?commit=#{sha}"
end
......
......@@ -34,7 +34,7 @@ class CiService < Service
# Ex.
# http://jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c
#
def build_page(sha)
def build_page(sha, ref)
# implement inside child
end
......@@ -51,7 +51,7 @@ class CiService < Service
# # => 'running'
#
#
def commit_status(sha)
def commit_status(sha, ref)
# implement inside child
end
end
......@@ -40,17 +40,17 @@ class GitlabCiService < CiService
service_hook.execute(data)
end
def commit_status_path(sha)
project_url + "/commits/#{sha}/status.json?token=#{token}"
def commit_status_path(sha, ref)
project_url + "/refs/#{ref}/commits/#{sha}/status.json?token=#{token}"
end
def get_ci_build(sha)
def get_ci_build(sha, ref)
@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
def commit_status(sha)
response = get_ci_build(sha)
def commit_status(sha, ref)
response = get_ci_build(sha, ref)
if response.code == 200 and response["status"]
response["status"]
......@@ -59,16 +59,16 @@ class GitlabCiService < CiService
end
end
def commit_coverage(sha)
response = get_ci_build(sha)
def commit_coverage(sha, ref)
response = get_ci_build(sha, ref)
if response.code == 200 and response["coverage"]
response["coverage"]
end
end
def build_page(sha)
project_url + "/commits/#{sha}"
def build_page(sha, ref)
project_url + "/refs/#{ref}/commits/#{sha}"
end
def builds_path
......
......@@ -88,7 +88,7 @@ class TeamcityService < CiService
@response = HTTParty.get("#{url}", verify: false, basic_auth: auth)
end
def build_page(sha)
def build_page(sha, ref)
build_info(sha) if @response.nil? || !@response.code
if @response.code != 200
......@@ -103,7 +103,7 @@ class TeamcityService < CiService
end
end
def commit_status(sha)
def commit_status(sha, ref)
build_info(sha) if @response.nil? || !@response.code
return :error unless @response.code == 200 || @response.code == 404
......
......@@ -59,7 +59,7 @@ describe BuildboxService do
describe :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'
)
end
......
......@@ -39,11 +39,11 @@ describe GitlabCiService do
end
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
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
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