Commit ce068023 authored by Furkan Ayhan's avatar Furkan Ayhan

Implement displaying downstream pipeline error details

Sometimes downstream pipelines can not be created.
We need to show why it happens to users.
In this implementation, we store downstream pipeline error message
in options attribute of bridge. And we display it.
parent 4c1dff36
......@@ -47,6 +47,7 @@ module Ci
# and update the status when the downstream pipeline completes.
subject.success! unless subject.dependent?
else
subject.options[:downstream_errors] = pipeline.errors.full_messages
subject.drop!(:downstream_pipeline_creation_failed)
end
end
......
---
title: Implement displaying downstream pipeline error details
merge_request: 32844
author:
type: fixed
......@@ -5,6 +5,14 @@ module Gitlab
module Status
module Bridge
class Failed < Status::Build::Failed
private
def failure_reason_message
[
self.class.reasons.fetch(subject.failure_reason.to_sym),
subject.options[:downstream_errors]
].flatten.compact.join(', ')
end
end
end
end
......
......@@ -59,12 +59,13 @@ describe Gitlab::Ci::Status::Bridge::Factory do
context 'failed with downstream_pipeline_creation_failed' do
before do
bridge.options = { downstream_errors: ['No stages / jobs for this pipeline.', 'other error'] }
bridge.failure_reason = 'downstream_pipeline_creation_failed'
end
it 'fabricates correct status_tooltip' do
expect(status.status_tooltip).to eq(
"#{s_('CiStatusText|failed')} - (downstream pipeline can not be created)"
"#{s_('CiStatusText|failed')} - (downstream pipeline can not be created, No stages / jobs for this pipeline., other error)"
)
end
end
......
......@@ -487,10 +487,11 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
end
it 'does not create a pipeline and drops the bridge' do
service.execute(bridge)
expect { service.execute(bridge) }.not_to change(downstream_project.ci_pipelines, :count)
expect(bridge.reload).to be_failed
expect(bridge.failure_reason).to eq('downstream_pipeline_creation_failed')
expect(bridge.options[:downstream_errors]).to eq(['Reference not found'])
end
end
......@@ -509,10 +510,35 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
end
it 'does not create a pipeline and drops the bridge' do
service.execute(bridge)
expect { service.execute(bridge) }.not_to change(downstream_project.ci_pipelines, :count)
expect(bridge.reload).to be_failed
expect(bridge.failure_reason).to eq('downstream_pipeline_creation_failed')
expect(bridge.options[:downstream_errors]).to eq(['No stages / jobs for this pipeline.'])
end
end
context 'when downstream pipeline has invalid YAML' do
before do
stub_ci_pipeline_yaml_file(config)
end
let(:config) do
<<-EOY
test:
stage: testx
script: echo 1
EOY
end
it 'creates the pipeline but drops the bridge' do
expect { service.execute(bridge) }.to change(downstream_project.ci_pipelines, :count).by(1)
expect(bridge.reload).to be_failed
expect(bridge.failure_reason).to eq('downstream_pipeline_creation_failed')
expect(bridge.options[:downstream_errors]).to eq(
['test job: chosen stage does not exist; available stages are .pre, build, test, deploy, .post']
)
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