Skip to content
Snippets Groups Projects
Commit f5ea19c8 authored by Kamil Trzciński's avatar Kamil Trzciński :speech_balloon: Committed by Doug Stull
Browse files

Add `object_attributes.name` to `pipeline_hooks`

This exposes `workflow: name:` of the pipeline.

Changelog: added
parent 14bfdd9d
No related branches found
No related tags found
1 merge request!123639Add `object_attributes.name` to `pipeline_hooks`
...@@ -1110,6 +1110,9 @@ and later, the pipeline webhook returns only the latest jobs. ...@@ -1110,6 +1110,9 @@ and later, the pipeline webhook returns only the latest jobs.
In [GitLab 15.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89546) In [GitLab 15.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/89546)
and later, pipeline webhooks triggered by blocked users are not processed. and later, pipeline webhooks triggered by blocked users are not processed.
In [GitLab 16.1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123639)
and later, pipeline webhooks started to expose `object_attributes.name`.
Request header: Request header:
```plaintext ```plaintext
...@@ -1124,6 +1127,7 @@ Payload example: ...@@ -1124,6 +1127,7 @@ Payload example:
"object_attributes":{ "object_attributes":{
"id": 31, "id": 31,
"iid": 3, "iid": 3,
"name": "Pipeline for branch: master",
"ref": "master", "ref": "master",
"tag": false, "tag": false,
"sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2", "sha": "bcbb5ec396a2c0f828686f14fac9b80b780504f2",
......
...@@ -65,6 +65,7 @@ def hook_attrs(pipeline) ...@@ -65,6 +65,7 @@ def hook_attrs(pipeline)
{ {
id: pipeline.id, id: pipeline.id,
iid: pipeline.iid, iid: pipeline.iid,
name: pipeline.name,
ref: pipeline.source_ref, ref: pipeline.source_ref,
tag: pipeline.tag, tag: pipeline.tag,
sha: pipeline.sha, sha: pipeline.sha,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::DataBuilder::Pipeline do RSpec.describe Gitlab::DataBuilder::Pipeline, feature_category: :continuous_integration do
let_it_be(:user) { create(:user, :public_email) } let_it_be(:user) { create(:user, :public_email) }
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
it 'has correct attributes', :aggregate_failures do it 'has correct attributes', :aggregate_failures do
expect(attributes).to be_a(Hash) expect(attributes).to be_a(Hash)
expect(attributes[:name]).to be_nil
expect(attributes[:ref]).to eq(pipeline.ref) expect(attributes[:ref]).to eq(pipeline.ref)
expect(attributes[:sha]).to eq(pipeline.sha) expect(attributes[:sha]).to eq(pipeline.sha)
expect(attributes[:tag]).to eq(pipeline.tag) expect(attributes[:tag]).to eq(pipeline.tag)
...@@ -54,6 +55,16 @@ ...@@ -54,6 +55,16 @@
expect(data[:source_pipeline]).to be_nil expect(data[:source_pipeline]).to be_nil
end end
context 'pipeline with metadata' do
let_it_be_with_reload(:pipeline_metadata) do
create(:ci_pipeline_metadata, pipeline: pipeline, name: "My Pipeline")
end
it 'has pipeline name', :aggregate_failures do
expect(attributes[:name]).to eq("My Pipeline")
end
end
context 'build with runner' do context 'build with runner' do
let_it_be(:tag_names) { %w(tag-1 tag-2) } let_it_be(:tag_names) { %w(tag-1 tag-2) }
let_it_be(:ci_runner) { create(:ci_runner, tag_list: tag_names.map { |n| ActsAsTaggableOn::Tag.create!(name: n) }) } let_it_be(:ci_runner) { create(:ci_runner, tag_list: tag_names.map { |n| ActsAsTaggableOn::Tag.create!(name: n) }) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment