Skip to content

Allow variables in job tags defined in parallel:matrix

Problem to solve

As a build engineer or software developer, I want to be able to use the feature parallel:matrix and pass the variables specified there to the job tags so that I can have a matrix-based data-driven control of the runners that will be building my pipelines.

Intended users

User experience goal

The user who is taking advantage of parallel:matrix should be able to use the variables specified in the matrix as job tags when writing the pipeline YAML file.

Proposal

Give the ability to use variables defined in parallel:matrix in job tags:

linux:
  tags:
    - ${VAR1}
    - ${VAR2}
  parallel:
    matrix:
      - VAR1: [value1, value2]
        VAR2: [value1, value2]

Further details

With the recent introduction of parallel:matrix, having the possibility of using the matrix variables in the tags would greatly reduce the complexity/redundancy of the pipeline code. For instance, I'm working with C++ code that needs to be compiled on different platforms, so I need to write the following to get it executed on a linux runner and a windows runner:

linux:
  tags:
    - linux
  script:
    - conan create . --profile ${ARCHITECTURE}_linux_${BUILD_TYPE}
  parallel:
    matrix:
      - BUILD_TYPE: [debug, release]
        ARCHITECTURE: [x64, x86]

windows:
  tags:
    - vfx20
    - windows
  script:
    - conan create . --profile ${ARCHITECTURE}_windows_${BUILD_TYPE}
  parallel:
    matrix:
      - BUILD_TYPE: [debug, release]
        ARCHITECTURE: [x64, x86]

With variables-in-tags this whole block would become:

build:
  tags:
    - ${OPERATING_SYSTEM}
  script:
    - conan create . --profile ${ARCHITECTURE}_${OPERATING_SYSTEM}_${BUILD_TYPE}
  parallel:
    matrix:
      - BUILD_TYPE: [debug, release]
        ARCHITECTURE: [x64, x86]
        OPERATING_SYSTEM: [linux, windows]

Permissions and Security

Following groups should have access to this new feature as they can edit the pipeline files:

  • Developer (30) members
  • Maintainer (40) members
  • Owner (50) members

Documentation

Availability & Testing

Additional test would be required to check if variable substitution in tags is successful or not.

What does success look like, and how can we measure that?

  • Success metrics:
    • Ability to change the selected runner using CI/CD variables defined in parallel:matrix without further need of editing other code
  • Acceptance criteria:
    • Environment variables are substituting correctly inside the job tags settings

What is the type of buyer?

Core

Links / references

https://docs.gitlab.com/ee/ci/yaml/#tags

Technical Details

  • Tags need to accept and expand variables -> similar to environment:name, which is then used in the pipeline seed phase
  • The parallel:matrix values are already set as variables
  • No additional changes need to be made to the linter
Edited by Laura Montemayor