firecow / gitlab-ci-local

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

The gitlab only condition is not work #1228

Closed WCY91 closed 1 month ago

WCY91 commented 1 month ago

Minimal .gitlab-ci.yml illustrating the issue

---
job:
  script:
    - echo $TASK
    - echo "This job runs only when the task variable is set to 'shift'."
  only:
    variables:
      - $TASK == "shift"

Expected behavior the task value is not equal "shift" but it also can work when i run the gitlab ci-local

Host information Mac gitlab-ci-local latest

Containerd binary using docker

PigeonF commented 1 month ago

I believe the only keyword is deprecated by gitlab.

You can use rules instead.

---
job:
  script:
    - echo $TASK
    - echo "This job runs only when the task variable is set to 'shift'."
  rules:
    - if: $TASK == "shift"
$ gitlab-ci-local --variable TASK=shift --list
name  description  stage   when        allow_failure  needs
job                test    on_success  false
$ gitlab-ci-local --variable TASK=other --list
name  description  stage   when        allow_failure  needs
WCY91 commented 1 month ago

Thanks for reply my question ,I use the only condition on gitlab server it can work and I set variable value by .gitlab-ci-local-variables.yml

firecow commented 1 month ago

We are not going to implement this deprecated feature.