Skip to content

Support needs specified inside rules #1602

@compiaffe

Description

@compiaffe

Minimal .gitlab-ci.yml illustrating the issue

variables:
  OVERRIDE_NEEDS_TO: "a"
build-a:
  stage: build
  script: echo "Feature branch, so building dev version..."

build-b:
  stage: build
  script: echo "Default branch, so building prod version..."

tests:
  stage: test
  needs:
    - job: build-a
      optional: true
    - job: build-b
      optional: true
  rules:
    - if: $OVERRIDE_NEEDS_TO == "a"
      needs: ['build-a']
    - if: $OVERRIDE_NEEDS_TO == "b"
      needs: ['build-b']
  script: echo "Running dev specs by default, or prod specs when default branch..."

Experienced output

❯ gitlab-ci-local --list
Using fallback git commit data
Unable to retrieve default remote branch, falling back to `main`. The default remote branch can be set via `git remote set-head origin <default_branch>`Using fallback git remote data
parsing and downloads finished in 51 ms.
json schema validated in 133 ms
name     description  stage   when        allow_failure  needs
build-a               build   on_success  false
build-b               build   on_success  false
tests                 test    on_success  false          [build-a,build-b]

Expected behavior

Tests to have a non-optional dependency on build-a only

Host information
CachyOS
gitlab-ci-local 4.60.0
Containerd binary
No, running this directly

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature missing according to gitlab ci standard

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions