Dynamic Needs on CI/CD Components

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem Statement

Currently, needs blocks for CI/CD components cannot be dynamically included, only dynamically populated with a value.

$[[ inputs.APP_CUSTOMER ]]-$[[ inputs.ENVIRONMENT ]]-diff:
  stage: '$[[ inputs.ENVIRONMENT ]]:diff'
  image:
    name: $IMAGE
  needs: [$[[ inputs.APP_CUSTOMER ]]-$[[ inputs.PRECEDING_ENVIRONMENT ]]-deploy]

In the above example, needs cannot be excluded, only mutated or left as an "empty" value of -deploy.

Proposal (suggested by @fabiopitino)

Using rules, allow for the dynamic inclusion of needs:

$[[ inputs.APP_CUSTOMER ]]-$[[ inputs.ENVIRONMENT ]]-diff:
  stage: '$[[ inputs.ENVIRONMENT ]]:diff'
  image:
    name: $IMAGE
  rules:
    - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /release-candidate\/RM-\d{4}-.*$[[ inputs.APP_CUSTOMER ]]$/ && $CI_PIPELINE_SOURCE == "merge_request_event"'
      needs: [$[[ inputs.APP_CUSTOMER ]]-$[[ inputs.PRECEDING_ENVIRONMENT ]]-deploy]

GitLab Premium

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited by 🤖 GitLab Bot 🤖