Commit ac7dd2d8 authored by Jacopo's avatar Jacopo

Correctly send notification on pipeline retry

Fix UpdateCiRefService in order to correctly trigger a ref update
on pipeline retry.
Updating the ref implies also sending a notification to
the related users.
parent 92e160e6
...@@ -22,7 +22,7 @@ module Ci ...@@ -22,7 +22,7 @@ module Ci
begin begin
retry_optimistic_lock(ref) do retry_optimistic_lock(ref) do
next false if ref.persisted? && next false if ref.persisted? &&
(ref.last_updated_by_pipeline_id || 0) >= pipeline.id (ref.last_updated_by_pipeline_id || 0) > pipeline.id
ref.update(status: next_status(ref.status, pipeline.status), ref.update(status: next_status(ref.status, pipeline.status),
last_updated_by_pipeline: pipeline) last_updated_by_pipeline: pipeline)
......
---
title: Correctly send notification on pipeline retry
merge_request: 26803
author: Jacopo Beschi @jacopo-beschi
type: fixed
...@@ -119,6 +119,14 @@ describe Ci::UpdateCiRefStatusService do ...@@ -119,6 +119,14 @@ describe Ci::UpdateCiRefStatusService do
it_behaves_like 'does a noop' it_behaves_like 'does a noop'
end end
context 'pipeline is retried' do
before do
ci_ref.update!(last_updated_by_pipeline: pipeline)
end
it_behaves_like 'updates ci_ref'
end
context 'ref is stale' do context 'ref is stale' do
let(:pipeline1) { create(:ci_pipeline, :success, project: ci_ref.project, ref: ci_ref.ref, tag: ci_ref.tag) } let(:pipeline1) { create(:ci_pipeline, :success, project: ci_ref.project, ref: ci_ref.ref, tag: ci_ref.tag) }
let(:pipeline2) { create(:ci_pipeline, :success, project: ci_ref.project, ref: ci_ref.ref, tag: ci_ref.tag) } let(:pipeline2) { create(:ci_pipeline, :success, project: ci_ref.project, ref: ci_ref.ref, tag: ci_ref.tag) }
......
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