needs

Run a job as soon as its dependencies finish, without waiting for the whole stage.

Supported: artifacts, pipeline:job, optional, parallel:matrix

Not supported: project (cross-project), pipeline (upstream)

Examples

Download artifacts from dependency

build:
  stage: build
  script:
    - mkdir dist
    - echo "artifact" > dist/output.txt
  artifacts:
    paths:
      - dist/

test:
  stage: test
  script: echo "test"
  needs:
    - job: build
      artifacts: true

Without downloading artifacts

build:
  stage: build
  script: echo "build"

test:
  stage: test
  script: echo "test"
  needs:
    - job: build
      artifacts: false

Optional dependency

build:
  stage: build
  script: echo "build"

test:
  stage: test
  script: echo "test"
  needs:
    - job: build
      optional: true

Parallel matrix dependency

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

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