diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-20 22:42:32 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-20 22:42:32 +0000 |
commit | 5738afdb12162683f12b4fce8a4d6646ddca9c60 (patch) | |
tree | 9ac3ad5a9eb5a8ee89bbb04f23208ffd612ba918 | |
parent | 9f9fed4fa2446edfdc2295fa1e910e9ed09ca677 (diff) | |
parent | e5fe14b2fb6590e71c7853d38ff74f32bc6b4ed4 (diff) | |
download | gitlab-ce-5738afdb12162683f12b4fce8a4d6646ddca9c60.tar.gz |
Merge branch 'link_to_ci_with_ref' into 'master'
Link to CI with ref
gitlab/gitlab-ci#162
!!! Should be merged simultaneously with https://dev.gitlab.org/gitlab/gitlab-ci/merge_requests/129
See merge request !1638
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 4 | ||||
-rw-r--r-- | app/helpers/merge_requests_helper.rb | 2 | ||||
-rw-r--r-- | app/models/project_services/bamboo_service.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/buildbox_service.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/ci_service.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/gitlab_ci_service.rb | 20 | ||||
-rw-r--r-- | app/models/project_services/teamcity_service.rb | 4 | ||||
-rw-r--r-- | spec/models/project_services/buildbox_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_services/gitlab_ci_service_spec.rb | 4 |
10 files changed, 25 insertions, 24 deletions
diff --git a/CHANGELOG b/CHANGELOG index f38a075fff5..07d0b5920bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index c63a9b0cd44..e9b7d7e0083 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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 = { diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 3b1589da57f..51b60770e0b 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -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) diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb index 0100f1e4a10..f968afe9fa8 100644 --- a/app/models/project_services/bamboo_service.rb +++ b/app/models/project_services/bamboo_service.rb @@ -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 diff --git a/app/models/project_services/buildbox_service.rb b/app/models/project_services/buildbox_service.rb index 270863c1576..fef1c9b7349 100644 --- a/app/models/project_services/buildbox_service.rb +++ b/app/models/project_services/buildbox_service.rb @@ -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 diff --git a/app/models/project_services/ci_service.rb b/app/models/project_services/ci_service.rb index c6f6b4952c9..1a36e439245 100644 --- a/app/models/project_services/ci_service.rb +++ b/app/models/project_services/ci_service.rb @@ -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 diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb index d81623625c9..edaeeffc228 100644 --- a/app/models/project_services/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -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 diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb index 7403e19da9a..c26bc551352 100644 --- a/app/models/project_services/teamcity_service.rb +++ b/app/models/project_services/teamcity_service.rb @@ -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 diff --git a/spec/models/project_services/buildbox_service_spec.rb b/spec/models/project_services/buildbox_service_spec.rb index 39d7df54cf0..fcbf3e45b9a 100644 --- a/spec/models/project_services/buildbox_service_spec.rb +++ b/spec/models/project_services/buildbox_service_spec.rb @@ -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 diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb index 8bfb19e524b..610f33c5823 100644 --- a/spec/models/project_services/gitlab_ci_service_spec.rb +++ b/spec/models/project_services/gitlab_ci_service_spec.rb @@ -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 |