From a85e65d45a80152cf0f1f776364a350ecc3cfc79 Mon Sep 17 00:00:00 2001 From: Vlad Wolanyk <vwolanyk@gitlab.com> Date: Tue, 23 Jul 2024 21:57:23 +0000 Subject: [PATCH] Update pipeline presenter updates copy for workflow rules and rules failure messages --- app/models/ci/pipeline.rb | 1 + .../concerns/ci/has_completion_reason.rb | 22 +++++++++++++++++ app/presenters/ci/pipeline_presenter.rb | 7 +++--- .../merge_requests/refresh_service.rb | 7 +++++- .../downstream_pipelines_troubleshooting.md | 2 +- .../refresh_merge_request_service.rb | 13 +++++++--- .../system_notes/merge_train_service.rb | 7 ++---- .../two_merge_requests_on_train_spec.rb | 9 ++++--- .../chain/evaluate_workflow_rules_spec.rb | 2 +- .../Security/bas_latest_ci_yaml_spec.rb | 4 +--- .../api_discovery_gitlab_ci_yaml_spec.rb | 3 +-- .../api_fuzzing_gitlab_ci_yaml_spec.rb | 3 +-- .../api_fuzzing_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../api_security_gitlab_ci_yaml_spec.rb | 3 +-- ...api_security_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../container_scanning_gitlab_ci_yaml_spec.rb | 3 +-- ...ner_scanning_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../coverage_fuzzing_gitlab_ci_yaml_spec.rb | 6 ++--- ...rage_fuzzing_latest_gitlab_ci_yaml_spec.rb | 9 +++---- .../templates/dast_api_gitlab_ci_yaml_spec.rb | 3 +-- .../dast_api_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../ci/templates/dast_gitlab_ci_yaml_spec.rb | 12 ++++------ .../dast_latest_gitlab_ci_yaml_spec.rb | 3 +-- ...dependency_scanning_gitlab_ci_yaml_spec.rb | 9 +++---- ...ncy_scanning_latest_gitlab_ci_yaml_spec.rb | 12 ++++------ .../ci/templates/sast_gitlab_ci_yaml_spec.rb | 6 ++--- .../templates/sast_iac_gitlab_ci_yaml_spec.rb | 3 +-- .../sast_latest_gitlab_ci_yaml_spec.rb | 9 +++---- .../secret_detection_gitlab_ci_yaml_spec.rb | 3 +-- ...et_detection_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../create_pipeline_service_spec.rb | 7 ++---- .../refresh_merge_request_service_spec.rb | 15 +++++++++--- .../system_notes/merge_train_service_spec.rb | 11 +++++++-- .../pipeline/chain/evaluate_workflow_rules.rb | 2 +- lib/gitlab/ci/pipeline/chain/populate.rb | 3 +-- .../chain/evaluate_workflow_rules_spec.rb | 2 +- .../gitlab/ci/pipeline/chain/populate_spec.rb | 3 +-- .../gitlab/ci/status/bridge/factory_spec.rb | 6 ++--- .../Jobs/code_quality_gitlab_ci_yaml_spec.rb | 9 +++---- .../Jobs/sast_iac_gitlab_ci_yaml_spec.rb | 6 ++--- .../sast_iac_latest_gitlab_ci_yaml_spec.rb | 6 ++--- .../Jobs/test_gitlab_ci_yaml_spec.rb | 9 +++---- spec/lib/gitlab/ci/templates/npm_spec.rb | 3 +-- .../terraform_latest_gitlab_ci_yaml_spec.rb | 5 +--- .../templates/themekit_gitlab_ci_yaml_spec.rb | 3 +-- ...create_downstream_pipeline_service_spec.rb | 6 ++--- .../ci/create_pipeline_service/rules_spec.rb | 15 ++++++------ .../ci/create_pipeline_service_spec.rb | 24 +++++++------------ 48 files changed, 151 insertions(+), 175 deletions(-) create mode 100644 app/models/concerns/ci/has_completion_reason.rb diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index fdef3f3e55e6d..f37fa2edcf81c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -4,6 +4,7 @@ module Ci class Pipeline < Ci::ApplicationRecord include Ci::Partitionable include Ci::HasStatus + include Ci::HasCompletionReason include Importable include AfterCommitQueue include Presentable diff --git a/app/models/concerns/ci/has_completion_reason.rb b/app/models/concerns/ci/has_completion_reason.rb new file mode 100644 index 0000000000000..b725d900f88de --- /dev/null +++ b/app/models/concerns/ci/has_completion_reason.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Ci + module HasCompletionReason + extend ActiveSupport::Concern + + class_methods do + def rules_failure_message + "the resulting pipeline would have been empty. Review the " \ + "[rules](#{Rails.application.routes.url_helpers.help_page_url('ci/yaml/index', anchor: 'rules')}) " \ + "configuration for the relevant jobs." + end + + def workflow_rules_failure_message + "the pipeline did not run. Review the " \ + "[workflow:rules](#{Rails.application.routes.url_helpers.help_page_url('ci/yaml/index', + anchor: 'workflowrules')}) " \ + "configuration for the pipeline." + end + end + end +end diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 6c7608b8067dc..c609cb35d9d6f 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -12,14 +12,13 @@ def self.failure_reasons { unknown_failure: 'The reason for the pipeline failure is unknown.', config_error: 'The pipeline failed due to an error on the CI/CD configuration file.', external_validation_failure: 'The external pipeline validation failed.', - user_not_verified: 'The pipeline failed due to the user not being verified', + user_not_verified: 'The pipeline failed due to the user not being verified.', size_limit_exceeded: 'The pipeline size limit was exceeded.', job_activity_limit_exceeded: 'The pipeline job activity limit was exceeded.', deployments_limit_exceeded: 'The pipeline deployments limit was exceeded.', project_deleted: 'The project associated with this pipeline was deleted.', - filtered_by_rules: 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.', - filtered_by_workflow_rules: 'Pipeline filtered out by workflow rules.' } + filtered_by_rules: Ci::Pipeline.rules_failure_message, + filtered_by_workflow_rules: Ci::Pipeline.workflow_rules_failure_message } end presents ::Ci::Pipeline, as: :pipeline diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index fbf3a48ac12c4..8f6979460a9c4 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -193,7 +193,12 @@ def abort_auto_merges?(merge_request) def abort_auto_merges(merge_request) return unless abort_auto_merges?(merge_request) - abort_auto_merge(merge_request, 'source branch was updated') + learn_more_url = Rails.application.routes.url_helpers.help_page_url( + 'ci/pipelines/merge_trains', + anchor: 'merge-request-dropped-from-the-merge-train' + ) + + abort_auto_merge(merge_request, "the source branch was updated. [Learn more](#{learn_more_url}).") end def abort_ff_merge_requests_with_auto_merges diff --git a/doc/ci/pipelines/downstream_pipelines_troubleshooting.md b/doc/ci/pipelines/downstream_pipelines_troubleshooting.md index fc5477074a0d9..12f160cc53a4a 100644 --- a/doc/ci/pipelines/downstream_pipelines_troubleshooting.md +++ b/doc/ci/pipelines/downstream_pipelines_troubleshooting.md @@ -31,7 +31,7 @@ the child pipeline must [use `workflow:rules` or `rules` to ensure the jobs run] If no jobs in the child pipeline can run due to missing or incorrect `rules` configuration: - The child pipeline fails to start. -- The parent pipeline's trigger job fails with: `downstream pipeline can not be created, Pipeline will not run for the selected trigger. The rules configuration prevented any jobs from being added to the pipeline.` +- The parent pipeline's trigger job fails with: `downstream pipeline can not be created, the resulting pipeline would have been empty. Review the`[`rules`](../yaml/index.md#rules)`configuration for the relevant jobs.` ## Variable with `$` character does not get passed to a downstream pipeline properly diff --git a/ee/app/services/merge_trains/refresh_merge_request_service.rb b/ee/app/services/merge_trains/refresh_merge_request_service.rb index d361b2b3018a1..1e3eeeb92963b 100644 --- a/ee/app/services/merge_trains/refresh_merge_request_service.rb +++ b/ee/app/services/merge_trains/refresh_merge_request_service.rb @@ -35,18 +35,25 @@ def validate! end if !merge_request.open? || merge_request.broken? || merge_request.draft? - raise ProcessError, 'merge request is not mergeable' + raise ProcessError, "the merge request is not mergeable. [Learn more](#{learn_more_url})." end unless merge_train_car.previous_ref_sha.present? - raise ProcessError, 'previous ref does not exist' + raise ProcessError, "the previous ref does not exist. [Learn more](#{learn_more_url})." end if merge_train_car.pipeline_not_succeeded? - raise ProcessError, 'pipeline did not succeed' + raise ProcessError, "the pipeline did not succeed. [Learn more](#{learn_more_url})." end end + def learn_more_url + Rails.application.routes.url_helpers.help_page_url( + 'ci/pipelines/merge_trains', + anchor: 'merge-request-dropped-from-the-merge-train' + ) + end + def merge_from_train_ref? # Although it should be technically safe to merge from any mergeable train # ref, do so for fast-forward and semi-linear merge trains to avoid diff --git a/ee/app/services/system_notes/merge_train_service.rb b/ee/app/services/system_notes/merge_train_service.rb index 7a02f75f8ab0e..34f9060280b76 100644 --- a/ee/app/services/system_notes/merge_train_service.rb +++ b/ee/app/services/system_notes/merge_train_service.rb @@ -29,11 +29,8 @@ def abort(reason) ## # TODO: Abort message should be sent by the system, not a particular user. # See https://gitlab.com/gitlab-org/gitlab/issues/29467. - url = Rails.application.routes.url_helpers.help_page_url( - 'ci/pipelines/merge_trains', - anchor: 'merge-request-dropped-from-the-merge-train' - ) - body = "removed this merge request from the merge train because #{reason}. [Learn more](#{url})." + + body = "removed this merge request from the merge train because #{reason}" create_note(NoteSummary.new(noteable, project, author, body, action: 'merge')) end diff --git a/ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb b/ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb index cfb768d738abf..a240e8614f453 100644 --- a/ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb +++ b/ee/spec/features/merge_trains/two_merge_requests_on_train_spec.rb @@ -147,7 +147,8 @@ it_behaves_like 'drops merge request 1 from the merge train' do let(:system_note) do - 'removed this merge request from the merge train because pipeline did not succeed. [Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + 'removed this merge request from the merge train because the pipeline did not succeed. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' end end @@ -189,7 +190,8 @@ it_behaves_like 'drops merge request 1 from the merge train' do let(:system_note) do - 'removed this merge request from the merge train because source branch was updated. [Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + 'removed this merge request from the merge train because the source branch was updated. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' end end @@ -209,7 +211,8 @@ it_behaves_like 'drops merge request 1 from the merge train' do let(:system_note) do - 'removed this merge request from the merge train because merge request is not mergeable. [Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + 'removed this merge request from the merge train because the merge request is not mergeable. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' end end diff --git a/ee/spec/lib/ee/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb b/ee/spec/lib/ee/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb index fb2490547d165..07056754f25e4 100644 --- a/ee/spec/lib/ee/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb +++ b/ee/spec/lib/ee/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb @@ -88,7 +88,7 @@ end it 'attaches an error to the pipeline' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) end it 'saves workflow_rules_result' do diff --git a/ee/spec/lib/gitlab/ci/templates/Security/bas_latest_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/Security/bas_latest_ci_yaml_spec.rb index dc7a1e45a84eb..93b832db17369 100644 --- a/ee/spec/lib/gitlab/ci/templates/Security/bas_latest_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/Security/bas_latest_ci_yaml_spec.rb @@ -56,9 +56,7 @@ it 'skips branch pipelines when an open MR exists' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from ' \ - 'being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/api_discovery_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/api_discovery_gitlab_ci_yaml_spec.rb index a84ac48bd0904..e4542b83cecc1 100644 --- a/ee/spec/lib/gitlab/ci/templates/api_discovery_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/api_discovery_gitlab_ci_yaml_spec.rb @@ -89,8 +89,7 @@ it 'includes no jobs' do expect(build_names).to be_empty expect(pipeline.errors.full_messages).to match_array([ - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' + Ci::Pipeline.rules_failure_message ]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/api_fuzzing_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/api_fuzzing_gitlab_ci_yaml_spec.rb index 1199e6d6dee04..26f1f5d880359 100644 --- a/ee/spec/lib/gitlab/ci/templates/api_fuzzing_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/api_fuzzing_gitlab_ci_yaml_spec.rb @@ -134,8 +134,7 @@ it 'includes no jobs' do expect(build_names).to be_empty expect(pipeline.errors.full_messages).to match_array([ - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' + Ci::Pipeline.rules_failure_message ]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/api_fuzzing_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/api_fuzzing_latest_gitlab_ci_yaml_spec.rb index 9b8c6a1eab162..1b4122b9db392 100644 --- a/ee/spec/lib/gitlab/ci/templates/api_fuzzing_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/api_fuzzing_latest_gitlab_ci_yaml_spec.rb @@ -136,8 +136,7 @@ it 'includes no jobs' do expect(build_names).to be_empty expect(pipeline.errors.full_messages).to match_array([ - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' + Ci::Pipeline.rules_failure_message ]) end end @@ -150,8 +149,7 @@ it 'includes no jobs' do expect(build_names).to be_empty expect(pipeline.errors.full_messages).to match_array([ - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' + Ci::Pipeline.rules_failure_message ]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/api_security_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/api_security_gitlab_ci_yaml_spec.rb index 5ed62c4c52a27..7a46d908b5751 100644 --- a/ee/spec/lib/gitlab/ci/templates/api_security_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/api_security_gitlab_ci_yaml_spec.rb @@ -96,8 +96,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/api_security_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/api_security_latest_gitlab_ci_yaml_spec.rb index 2f1a284ea2530..18a83fb090689 100644 --- a/ee/spec/lib/gitlab/ci/templates/api_security_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/api_security_latest_gitlab_ci_yaml_spec.rb @@ -98,8 +98,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -110,8 +109,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb index 989b9077bd3b4..0411f5d59a3b4 100644 --- a/ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/container_scanning_gitlab_ci_yaml_spec.rb @@ -46,8 +46,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/container_scanning_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/container_scanning_latest_gitlab_ci_yaml_spec.rb index c266541fd1d47..8f9ede2abbfed 100644 --- a/ee/spec/lib/gitlab/ci/templates/container_scanning_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/container_scanning_latest_gitlab_ci_yaml_spec.rb @@ -80,8 +80,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -92,8 +91,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_gitlab_ci_yaml_spec.rb index 949002a5f986d..24df5a2d3577f 100644 --- a/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_gitlab_ci_yaml_spec.rb @@ -47,8 +47,7 @@ it 'includes no job' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -61,8 +60,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_latest_gitlab_ci_yaml_spec.rb index bcbcefd62dcad..228945973868c 100644 --- a/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/coverage_fuzzing_latest_gitlab_ci_yaml_spec.rb @@ -47,8 +47,7 @@ it 'includes no job' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -63,8 +62,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -75,8 +73,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/dast_api_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dast_api_gitlab_ci_yaml_spec.rb index 33766acd3050b..bcd5014e30757 100644 --- a/ee/spec/lib/gitlab/ci/templates/dast_api_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dast_api_gitlab_ci_yaml_spec.rb @@ -96,8 +96,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/dast_api_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dast_api_latest_gitlab_ci_yaml_spec.rb index 43d9d5bade548..5261e8368bfee 100644 --- a/ee/spec/lib/gitlab/ci/templates/dast_api_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dast_api_latest_gitlab_ci_yaml_spec.rb @@ -98,8 +98,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -110,8 +109,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb index 182fc45b3b1b1..d421034571838 100644 --- a/ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb @@ -49,8 +49,7 @@ context 'when project has no license' do it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -72,8 +71,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -107,8 +105,7 @@ context 'when on default branch' do it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -145,8 +142,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/dast_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dast_latest_gitlab_ci_yaml_spec.rb index 88384db4bbece..338b4c5312975 100644 --- a/ee/spec/lib/gitlab/ci/templates/dast_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dast_latest_gitlab_ci_yaml_spec.rb @@ -5,8 +5,7 @@ RSpec.shared_examples 'includes no jobs' do it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb index e8b89f5d4163b..bf3dc07fa9dce 100644 --- a/ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb @@ -132,8 +132,7 @@ context 'when project has no license' do it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -151,8 +150,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -189,8 +187,7 @@ it 'creates a pipeline excluding jobs from specified analyzers' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/dependency_scanning_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/dependency_scanning_latest_gitlab_ci_yaml_spec.rb index 3bdc09727c581..25d86b0c6e673 100644 --- a/ee/spec/lib/gitlab/ci/templates/dependency_scanning_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/dependency_scanning_latest_gitlab_ci_yaml_spec.rb @@ -171,8 +171,7 @@ context 'when project has no license' do it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -191,8 +190,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -203,8 +201,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -250,8 +247,7 @@ it 'creates a pipeline excluding jobs from specified analyzers' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/sast_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/sast_gitlab_ci_yaml_spec.rb index 554f554528891..b6c8ab5f397db 100644 --- a/ee/spec/lib/gitlab/ci/templates/sast_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/sast_gitlab_ci_yaml_spec.rb @@ -30,8 +30,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -44,8 +43,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/sast_iac_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/sast_iac_gitlab_ci_yaml_spec.rb index ab16efccd0fbe..f446551cdd12e 100644 --- a/ee/spec/lib/gitlab/ci/templates/sast_iac_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/sast_iac_gitlab_ci_yaml_spec.rb @@ -30,8 +30,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/ee/spec/lib/gitlab/ci/templates/sast_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/sast_latest_gitlab_ci_yaml_spec.rb index 5ce72ca563825..b5626648ea516 100644 --- a/ee/spec/lib/gitlab/ci/templates/sast_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/sast_latest_gitlab_ci_yaml_spec.rb @@ -37,8 +37,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -49,8 +48,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -73,8 +71,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/secret_detection_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/secret_detection_gitlab_ci_yaml_spec.rb index 389fb23350387..fff42b20fa9d8 100644 --- a/ee/spec/lib/gitlab/ci/templates/secret_detection_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/secret_detection_gitlab_ci_yaml_spec.rb @@ -30,8 +30,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/lib/gitlab/ci/templates/secret_detection_latest_gitlab_ci_yaml_spec.rb b/ee/spec/lib/gitlab/ci/templates/secret_detection_latest_gitlab_ci_yaml_spec.rb index baa8fe8d13f16..755bc34cfbedc 100644 --- a/ee/spec/lib/gitlab/ci/templates/secret_detection_latest_gitlab_ci_yaml_spec.rb +++ b/ee/spec/lib/gitlab/ci/templates/secret_detection_latest_gitlab_ci_yaml_spec.rb @@ -35,8 +35,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -47,8 +46,7 @@ it 'includes no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/ee/spec/services/merge_trains/create_pipeline_service_spec.rb b/ee/spec/services/merge_trains/create_pipeline_service_spec.rb index fff9ff7f60e90..5fc2e9fef50a1 100644 --- a/ee/spec/services/merge_trains/create_pipeline_service_spec.rb +++ b/ee/spec/services/merge_trains/create_pipeline_service_spec.rb @@ -35,7 +35,7 @@ specify do expect(subject[:status]).to eq(:error) - expect(subject[:message]).to match(/^#{expected_reason}/) + expect(subject[:message]).to match expected_reason end end @@ -146,10 +146,7 @@ context 'when .gitlab-ci.yml does not have only: [merge_requests] specification' do it_behaves_like 'returns an error' do - let(:expected_reason) do - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' - end + let(:expected_reason) { ::Ci::Pipeline.rules_failure_message } end end end diff --git a/ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb b/ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb index 868bc1c661799..e9c87842b20d3 100644 --- a/ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb +++ b/ee/spec/services/merge_trains/refresh_merge_request_service_spec.rb @@ -124,7 +124,10 @@ end it_behaves_like 'drops the merge request from the merge train' do - let(:expected_reason) { 'merge request is not mergeable' } + let(:expected_reason) do + 'the merge request is not mergeable. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + end end end @@ -136,7 +139,10 @@ end it_behaves_like 'drops the merge request from the merge train' do - let(:expected_reason) { 'pipeline did not succeed' } + let(:expected_reason) do + 'the pipeline did not succeed. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + end end end @@ -158,7 +164,10 @@ end it_behaves_like 'drops the merge request from the merge train' do - let(:expected_reason) { 'previous ref does not exist' } + let(:expected_reason) do + 'the previous ref does not exist. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + end end end diff --git a/ee/spec/services/system_notes/merge_train_service_spec.rb b/ee/spec/services/system_notes/merge_train_service_spec.rb index cf29802210177..b9198cc0a3b1a 100644 --- a/ee/spec/services/system_notes/merge_train_service_spec.rb +++ b/ee/spec/services/system_notes/merge_train_service_spec.rb @@ -55,7 +55,11 @@ end describe '#abort' do - subject { described_class.new(noteable: noteable, project: project, author: author).abort('source branch was updated') } + subject do + described_class.new(noteable: noteable, project: project, author: author) + .abort('the source branch was updated. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).') + end let(:noteable) { create(:merge_request, :on_train, source_project: project, target_project: project) } @@ -64,7 +68,10 @@ end it "posts the 'merge train' system note" do - expect(subject.note).to eq('removed this merge request from the merge train because source branch was updated. [Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).') + expect(subject.note).to eq( + 'removed this merge request from the merge train because the source branch was updated. ' \ + '[Learn more](http://localhost/help/ci/pipelines/merge_trains#merge-request-dropped-from-the-merge-train).' + ) end it_behaves_like 'creates a removed merge train TODO' diff --git a/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules.rb b/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules.rb index 04195e4f84807..fca7bf1ab084f 100644 --- a/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules.rb +++ b/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules.rb @@ -28,7 +28,7 @@ def perform! end error( - 'Pipeline filtered out by workflow rules.', + ::Ci::Pipeline.workflow_rules_failure_message, failure_reason: :filtered_by_workflow_rules ) end diff --git a/lib/gitlab/ci/pipeline/chain/populate.rb b/lib/gitlab/ci/pipeline/chain/populate.rb index 5b2cb7f759dcb..e5a2be755d85e 100644 --- a/lib/gitlab/ci/pipeline/chain/populate.rb +++ b/lib/gitlab/ci/pipeline/chain/populate.rb @@ -19,8 +19,7 @@ def perform! if no_pipeline_to_create? return error( - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.', + ::Ci::Pipeline.rules_failure_message, failure_reason: :filtered_by_rules ) end diff --git a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb index bf14679165932..761dccf3d4261 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules_spec.rb @@ -33,7 +33,7 @@ end it 'attaches an error to the pipeline' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) end it 'saves workflow_rules_result' do diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb index 85b0abb554839..544650da18d37 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb @@ -90,8 +90,7 @@ def run_chain it 'appends an error about missing stages' do expect(pipeline.errors.to_a) - .to include 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' + .to include ::Ci::Pipeline.rules_failure_message end it 'wastes pipeline iid' do diff --git a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb index 6c8daf4bfb1bf..3e584e972f56e 100644 --- a/spec/lib/gitlab/ci/status/bridge/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/bridge/factory_spec.rb @@ -60,15 +60,13 @@ context 'failed with downstream_pipeline_creation_failed' do before do - bridge.options = { downstream_errors: ['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.', 'other error'] } + bridge.options = { downstream_errors: [Ci::Pipeline.rules_failure_message, 'other error'] } bridge.failure_reason = 'downstream_pipeline_creation_failed' end it 'fabricates correct status_tooltip' do expect(status.status_tooltip).to eq( - "#{s_('CiStatusLabel|Failed')} - (downstream pipeline can not be created, Pipeline will not run for the selected trigger. " \ - "The rules configuration prevented any jobs from being added to the pipeline., other error)" + "#{s_('CiStatusLabel|Failed')} - (downstream pipeline can not be created, #{Ci::Pipeline.rules_failure_message}, other error)" ) end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb index 286f3d10b7fa3..a729a95b8ac11 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/code_quality_gitlab_ci_yaml_spec.rb @@ -63,8 +63,7 @@ context 'on master' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -73,8 +72,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -83,8 +81,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb index 68d249e31f934..19dc8292c5404 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_gitlab_ci_yaml_spec.rb @@ -50,8 +50,7 @@ context 'on default branch' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -60,8 +59,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb index 86bc92597898b..514b3dd8bab5f 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/sast_iac_latest_gitlab_ci_yaml_spec.rb @@ -57,8 +57,7 @@ context 'on default branch' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -67,8 +66,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb index d73d8a15feb85..a5bae3e5a0be4 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/test_gitlab_ci_yaml_spec.rb @@ -63,8 +63,7 @@ context 'on master' do it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -73,8 +72,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end @@ -83,8 +81,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/spec/lib/gitlab/ci/templates/npm_spec.rb b/spec/lib/gitlab/ci/templates/npm_spec.rb index a949a7ccfb1a2..834b8daacd5cf 100644 --- a/spec/lib/gitlab/ci/templates/npm_spec.rb +++ b/spec/lib/gitlab/ci/templates/npm_spec.rb @@ -43,8 +43,7 @@ def create_tag(name:) shared_examples 'no pipeline created' do it 'does not create a pipeline because the only job (publish) is not created' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb index f84826efc49c3..dd9fe01ba7a8f 100644 --- a/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/terraform_latest_gitlab_ci_yaml_spec.rb @@ -79,10 +79,7 @@ it 'does not create a branch pipeline', :aggregate_failures do expect(branch_build_names).to be_empty expect(branch_pipeline.errors.full_messages).to match_array( - [ - 'Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.' - ] + [Ci::Pipeline.rules_failure_message] ) end end diff --git a/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb index 607db33f61a0d..1021da5ce5ca7 100644 --- a/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/themekit_gitlab_ci_yaml_spec.rb @@ -52,8 +52,7 @@ it 'has no jobs' do expect(build_names).to be_empty - expect(pipeline.errors.full_messages).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors.full_messages).to match_array([Ci::Pipeline.rules_failure_message]) end end end diff --git a/spec/services/ci/create_downstream_pipeline_service_spec.rb b/spec/services/ci/create_downstream_pipeline_service_spec.rb index 4eb6962cf47d8..c3e6876b57dff 100644 --- a/spec/services/ci/create_downstream_pipeline_service_spec.rb +++ b/spec/services/ci/create_downstream_pipeline_service_spec.rb @@ -777,13 +777,11 @@ it 'does not create a pipeline and drops the bridge' do expect { subject }.not_to change(downstream_project.ci_pipelines, :count) expect(subject).to be_error - expect(subject.message).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(subject.message).to match_array([Ci::Pipeline.rules_failure_message]) expect(bridge.reload).to be_failed expect(bridge.failure_reason).to eq('downstream_pipeline_creation_failed') - expect(bridge.options[:downstream_errors]).to match_array(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(bridge.options[:downstream_errors]).to match_array([Ci::Pipeline.rules_failure_message]) end end diff --git a/spec/services/ci/create_pipeline_service/rules_spec.rb b/spec/services/ci/create_pipeline_service/rules_spec.rb index ee9031cd7d17d..c5a0907f490d0 100644 --- a/spec/services/ci/create_pipeline_service/rules_spec.rb +++ b/spec/services/ci/create_pipeline_service/rules_spec.rb @@ -1309,7 +1309,7 @@ def find_job(name) let(:ref) { 'refs/heads/wip' } it 'invalidates the pipeline with a workflow rules error' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1318,7 +1318,7 @@ def find_job(name) let(:ref) { 'refs/heads/fix' } it 'invalidates the pipeline with a workflow rules error' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1375,7 +1375,7 @@ def find_job(name) let(:ref) { 'refs/heads/feature_conflict' } it 'invalidates the pipeline with a workflow rules error' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1401,8 +1401,7 @@ def find_job(name) let(:ref) { 'refs/heads/master' } it 'invalidates the pipeline with an empty jobs error' do - expect(pipeline.errors[:base]).to include('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1420,7 +1419,7 @@ def find_job(name) let(:ref) { 'refs/heads/fix' } it 'invalidates the pipeline with a workflow rules error' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1429,7 +1428,7 @@ def find_job(name) let(:ref) { 'refs/heads/wip' } it 'invalidates the pipeline with a workflow rules error' do - expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline.errors[:base]).to include(Ci::Pipeline.workflow_rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1621,7 +1620,7 @@ def find_job(name) end it 'creates the pipeline with a job' do - expect(pipeline.errors.full_messages).to eq(['Pipeline filtered out by workflow rules.']) + expect(pipeline.errors.full_messages).to eq([Ci::Pipeline.workflow_rules_failure_message]) expect(response).to be_error expect(pipeline).not_to be_persisted end diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index b5280c9c5fdbf..ce02bfea7f11e 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -694,8 +694,7 @@ def previous_commit_sha_from_ref(ref) result = execute_service expect(result).to be_error - expect(result.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(result.message).to eq(Ci::Pipeline.rules_failure_message) expect(result.payload).not_to be_persisted expect(Ci::Build.all).to be_empty expect(Ci::Pipeline.count).to eq(0) @@ -1265,11 +1264,9 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted - expect(pipeline.errors[:base]).to eq(['Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.']) + expect(pipeline.errors[:base]).to eq([Ci::Pipeline.rules_failure_message]) end end end @@ -1479,8 +1476,7 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1516,8 +1512,7 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1545,8 +1540,7 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1576,8 +1570,7 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end @@ -1605,8 +1598,7 @@ def previous_commit_sha_from_ref(ref) it 'does not create a detached merge request pipeline', :aggregate_failures do expect(response).to be_error - expect(response.message).to eq('Pipeline will not run for the selected trigger. ' \ - 'The rules configuration prevented any jobs from being added to the pipeline.') + expect(response.message).to eq(Ci::Pipeline.rules_failure_message) expect(pipeline).not_to be_persisted end end -- GitLab