firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.21k stars 125 forks source link

Missing jobs using "gitlab-ci-local --list" #1312

Closed heydonovan closed 1 month ago

heydonovan commented 1 month ago

Minimal .gitlab-ci.yml illustrating the issue

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID == null

build:docker:
  stage: build
  image: docker:24
  rules:
    - if: $DISABLE_BUILD == "true"
      when: never
    - when: always
  script: pwd

variables:
  DISABLE_BUILD: "false"

Expected behavior There should be a build:docker job listed when running gitlab-ci-local --list.

Host information

$ sw_vers
ProductName:        macOS
ProductVersion:     14.5
BuildVersion:       23F79

$ gitlab-ci-local --version
4.52.2

Containerd binary

$ docker --version
Docker version 27.1.1, build 6312585

Additional context This used to work, trying to figure out what version changed it. Even running --list-all shows it as never:

$ gitlab-ci-local --list-all
parsing and downloads finished in 73 ms.
name          description  stage   when   allow_failure  needs
build:docker               build   never  false
image
PigeonF commented 1 month ago

Hmm, I cannot reproduce on NixOS.

$ cat .gitlab-ci.yml
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID == null

build:docker:
  stage: build
  image: docker:24
  rules:
    - if: $DISABLE_BUILD == "true"
      when: never
    - when: always
  script: pwd

variables:
  DISABLE_BUILD: "false"
$ npx gitlab-ci-local@4.52.2 --list
Using fallback git commit data
Unable to retrieve default remote branch, falling back to `main`.
Using fallback git remote data
parsing and downloads finished in 53 ms.
json schema validated in 209 ms
name          description  stage   when    allow_failure  needs
build:docker               build   always  false
PigeonF commented 1 month ago

@heydonovan Does the job only not appear in --list, or does it also not run? That is, what happens if you just run gitlab-ci-local without any arguments? What happens if you run gitlab-ci-local "build:docker"?

heydonovan commented 1 month ago

Edit: Well this was fun! Turns out DISABLE_BUILD: "true" was defined in ~/.gitlab-ci-local/variables.yml. 😭

Forgot that file existed. I'll echo those variables before each run, just to remember them. Thanks y'all!