Commit 4d0032f0 authored by Matija Čupić's avatar Matija Čupić

Run PipelineBridgeWorker after Pipeline finishes

parent dd73af2e
......@@ -66,6 +66,10 @@ module HasStatus
def all_state_names
state_machines.values.flat_map(&:states).flat_map { |s| s.map(&:name) }
end
def completed_statuses
COMPLETED_STATUSES.map(&:to_sym)
end
end
included do
......
......@@ -88,7 +88,7 @@ module EE
}.freeze
state_machine :status do
after_transition any => ::Ci::Pipeline::COMPLETED_STATUSES.map(&:to_sym) do |pipeline|
after_transition any => ::Ci::Pipeline.completed_statuses do |pipeline|
next unless pipeline.has_reports?(::Ci::JobArtifact.security_reports) && pipeline.default_branch?
pipeline.run_after_commit do
......@@ -96,6 +96,14 @@ module EE
end
end
after_transition any => ::Ci::Pipeline.completed_statuses do |pipeline|
next unless pipeline.bridged_jobs.any?
pipeline.run_after_commit do
::Ci::PipelineBridgeWorker.perform_async(pipeline.id)
end
end
after_transition created: :pending do |pipeline|
next unless pipeline.bridge_triggered?
......
......@@ -440,6 +440,19 @@ describe Ci::Pipeline do
end
end
end
context 'when pipeline has bridged jobs' do
before do
pipeline.bridged_jobs << create(:ci_bridge)
end
context "when transitioning to success" do
it 'schedules the pipeline bridge worker' do
expect(::Ci::PipelineBridgeWorker).to receive(:perform_async).with(pipeline.id)
pipeline.succeed!
end
end
end
end
describe '#ci_yaml_file_path' do
......
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