Commit e0412dd4 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'eb-missing-dependencies-custom-callout-message' into 'master'

Specify failing dependencies in the callout message

See merge request gitlab-org/gitlab!18219
parents 4b07f874 393c9582
......@@ -130,6 +130,10 @@ export default {
return title;
},
shouldRenderHeaderCallout() {
return this.shouldRenderCalloutMessage && !this.hasUnmetPrerequisitesFailure;
},
},
watch: {
// Once the job log is loaded,
......@@ -239,10 +243,9 @@ export default {
/>
</div>
<callout
v-if="shouldRenderCalloutMessage && !hasUnmetPrerequisitesFailure"
:message="job.callout_message"
/>
<callout v-if="shouldRenderHeaderCallout">
<div v-html="job.callout_message"></div>
</callout>
</header>
<!-- EO Header Section -->
......
......@@ -754,6 +754,10 @@ module Ci
true
end
def invalid_dependencies
dependencies.reject(&:valid_dependency?)
end
def runner_required_feature_names
strong_memoize(:runner_required_feature_names) do
RUNNER_FEATURES.select do |feature, method|
......
......@@ -121,4 +121,28 @@ class BuildDetailsEntity < JobEntity
def can_admin_build?
can?(request.current_user, :admin_build, project)
end
def callout_message
return super unless build.failure_reason.to_sym == :missing_dependency_failure
docs_url = "https://docs.gitlab.com/ce/ci/yaml/README.html#dependencies"
[
failure_message.html_safe,
help_message(docs_url).html_safe
].join("<br />")
end
def invalid_dependencies
build.invalid_dependencies.map(&:name).join(', ')
end
def failure_message
_("This job depends on other jobs with expired/erased artifacts: %{invalid_dependencies}") %
{ invalid_dependencies: invalid_dependencies }
end
def help_message(docs_url)
_("Please refer to <a href=\"%{docs_url}\">%{docs_url}</a>") % { docs_url: docs_url }
end
end
---
title: Include in the callout message a list of jobs that caused missing dependencies
failure.
merge_request: 18219
author:
type: added
......@@ -11990,6 +11990,9 @@ msgstr ""
msgid "Please provide a valid email address."
msgstr ""
msgid "Please refer to <a href=\"%{docs_url}\">%{docs_url}</a>"
msgstr ""
msgid "Please retype the email address."
msgstr ""
......@@ -16752,6 +16755,9 @@ msgstr ""
msgid "This issue is locked."
msgstr ""
msgid "This job depends on other jobs with expired/erased artifacts: %{invalid_dependencies}"
msgstr ""
msgid "This job depends on upstream jobs that need to succeed in order for this job to be triggered"
msgstr ""
......
......@@ -3918,4 +3918,14 @@ describe Ci::Build do
end
end
end
describe '#invalid_dependencies' do
let!(:pre_stage_job_valid) { create(:ci_build, :manual, pipeline: pipeline, name: 'test1', stage_idx: 0) }
let!(:pre_stage_job_invalid) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test2', stage_idx: 1) }
let!(:job) { create(:ci_build, :pending, pipeline: pipeline, stage_idx: 2, options: { dependencies: %w(test1 test2) }) }
it 'returns invalid dependencies' do
expect(job.invalid_dependencies).to eq([pre_stage_job_invalid])
end
end
end
......@@ -123,6 +123,24 @@ describe BuildDetailsEntity do
end
it { is_expected.to include(failure_reason: 'unmet_prerequisites') }
it { is_expected.to include(callout_message: CommitStatusPresenter.callout_failure_messages[:unmet_prerequisites]) }
end
context 'when the build has failed due to a missing dependency' do
let!(:test1) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test1', stage_idx: 0) }
let!(:test2) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test2', stage_idx: 1) }
let!(:build) { create(:ci_build, :pending, pipeline: pipeline, stage_idx: 2, options: { dependencies: %w(test1 test2) }) }
let(:message) { subject[:callout_message] }
before do
build.drop!(:missing_dependency_failure)
end
it { is_expected.to include(failure_reason: 'missing_dependency_failure') }
it 'includes the failing dependencies in the callout message' do
expect(message).to include('test2, test1')
end
end
context 'when a build has environment with latest deployment' 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