Matrix jobs


Matrix jobs

Matrix jobs execute the same script with different inputs

Defined using parallel

Inputs are specified using environment variables

The matrix keyword under parallel defines variables sets

Example

job_name:
  parallel:
    matrix:
    - FOO: bar
      BAR: meh
    - FOO: baz
      BAR: [moo meh]
    - FOO: [ABC CED FGH]
      BAR: ruff

Using matrix inputs

Matrix variables can be used for…

Maximum of 200 parallel jobs

Example

job_name:
  parallel:
    matrix:
    - STAGE: [ qa, live ]
  image: reg.comp.org/${STAGE}/image:tag
  script: echo "${STAGE}"

Hands-On

See chapter Matrix jobs


Pro tip: Matrix jobs and needs

XXX

XXX extended syntax

linux:build:
  stage: build
  script: echo "Building linux..."
  parallel:
    matrix:
      - PROVIDER: aws
        STACK:
          - monitoring
          - app1
          - app2

linux:rspec:
  stage: test
  needs:
    - job: linux:build
      parallel:
        matrix:
          - PROVIDER: aws
            STACK: app1
  script: echo "Running rspec on linux..."