Commit 41f7a751 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'mc/api/pipeline-webhook-remove-retried-jobs' into 'master'

Send only latest jobs in pipeline webhook payload

See merge request gitlab-org/gitlab!53159
parents 5ba1bbf4 6ee0e543
---
title: Send only latest jobs in pipeline webhook payload.
merge_request: 53159
author:
type: fixed
......@@ -1029,6 +1029,9 @@ X-Gitlab-Event: Wiki Page Hook
### Pipeline events
In [GitLab 13.9](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53159)
and later, the pipeline webhook returns only the latest jobs.
Triggered on status change of Pipeline.
**Request Header**:
......
......@@ -13,7 +13,7 @@ module Gitlab
user: pipeline.user.try(:hook_attrs),
project: pipeline.project.hook_attrs(backward: false),
commit: pipeline.commit.try(:hook_attrs),
builds: pipeline.builds.map(&method(:build_hook_attrs))
builds: pipeline.builds.latest.map(&method(:build_hook_attrs))
}
end
......
......@@ -104,5 +104,16 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
expect(merge_request_attrs[:url]).to eq("http://localhost/#{merge_request.target_project.full_path}/-/merge_requests/#{merge_request.iid}")
end
end
context 'when pipeline has retried builds' do
before do
create(:ci_build, :retried, pipeline: pipeline)
end
it 'does not contain retried builds in payload' do
expect(data[:builds].count).to eq(1)
expect(build_data[:id]).to eq(build.id)
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