diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-05-28 08:16:26 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-06-03 13:08:50 +0000 |
commit | c5e5d4aa8c95bf668cb65f20d285d625c1fa4e8f (patch) | |
tree | d1c331a24f122f7d21767119326219f9285a4ed4 | |
parent | c416e630547d791ed6d15629d8af0c2e8d5b1125 (diff) | |
download | gitlab-ce-c5e5d4aa8c95bf668cb65f20d285d625c1fa4e8f.tar.gz |
Merge branch 'use-source-ref-name-in-webhook' into 'master'
Use source ref in pipeline webhook
Closes #61553
See merge request gitlab-org/gitlab-ce!28772
(cherry picked from commit 2714f85c1287e560d38c8de9f1f17c3aa3d4c8df)
7e05f3b7 Use source ref for pipeline webhook
-rw-r--r-- | changelogs/unreleased/use-source-ref-name-in-webhook.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/data_builder/pipeline.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/data_builder/pipeline_spec.rb | 9 |
3 files changed, 15 insertions, 1 deletions
diff --git a/changelogs/unreleased/use-source-ref-name-in-webhook.yml b/changelogs/unreleased/use-source-ref-name-in-webhook.yml new file mode 100644 index 00000000000..1a5c56d79ca --- /dev/null +++ b/changelogs/unreleased/use-source-ref-name-in-webhook.yml @@ -0,0 +1,5 @@ +--- +title: Use source ref in pipeline webhook +merge_request: 28772 +author: +type: fixed diff --git a/lib/gitlab/data_builder/pipeline.rb b/lib/gitlab/data_builder/pipeline.rb index fa06fb935f7..e1e813849bf 100644 --- a/lib/gitlab/data_builder/pipeline.rb +++ b/lib/gitlab/data_builder/pipeline.rb @@ -19,7 +19,7 @@ module Gitlab def hook_attrs(pipeline) { id: pipeline.id, - ref: pipeline.ref, + ref: pipeline.source_ref, tag: pipeline.tag, sha: pipeline.sha, before_sha: pipeline.before_sha, diff --git a/spec/lib/gitlab/data_builder/pipeline_spec.rb b/spec/lib/gitlab/data_builder/pipeline_spec.rb index 9ef987a0826..1f36fd5c6ef 100644 --- a/spec/lib/gitlab/data_builder/pipeline_spec.rb +++ b/spec/lib/gitlab/data_builder/pipeline_spec.rb @@ -50,5 +50,14 @@ describe Gitlab::DataBuilder::Pipeline do it { expect(attributes[:variables]).to be_a(Array) } it { expect(attributes[:variables]).to contain_exactly({ key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1' }) } end + + context 'when pipeline is a detached merge request pipeline' do + let(:merge_request) { create(:merge_request, :with_detached_merge_request_pipeline) } + let(:pipeline) { merge_request.all_pipelines.first } + + it 'returns a source ref' do + expect(attributes[:ref]).to eq(merge_request.source_branch) + end + end end end |