Skip to content

Implement needs:job:optional for CI pipelines [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Furkan Ayhan requested to merge 30680-job-needs-optional into master

What does this MR do?

This MR adds the support of the optional attribute for needs.

More info is available in the documentation change of this MR.

Copied from the new documentation:

Use optional: false (default) or optional: true to control if the needed job is required to persist in the pipeline.

Related to #30680 (closed)

This is behind a feature flag ci_needs_optional => #323891 (closed).

Screenshots (strongly suggested)

Example config:

build:
  stage: build
  rules:
    - if: $CI_COMMIT_REF_NAME == "master"

rspec:
  stage: test
  needs:
    - job: build
      optional: true

If the rules condition is not satisfied;

Before this MR:

Screen_Shot_2021-03-01_at_19.58.00

After this MR:

Screen_Shot_2021-03-01_at_19.55.15

Database outputs

Up

== 20210301193412 AddOptionalToCiBuildNeeds: migrating ========================
-- add_column(:ci_build_needs, :optional, :boolean, {:default=>false, :null=>false})
   -> 0.0056s
== 20210301193412 AddOptionalToCiBuildNeeds: migrated (0.0056s) ===============

Down

== 20210301193412 AddOptionalToCiBuildNeeds: reverting ========================
-- remove_column(:ci_build_needs, :optional, :boolean, {:default=>false, :null=>false})
   -> 0.0099s
== 20210301193412 AddOptionalToCiBuildNeeds: reverted (0.0128s) ===============

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Furkan Ayhan

Merge request reports