CICD variables under only not apply to create a job for pipeline

Gitlab version:
13.8.0-pre

Gitlab runner version:
latest(download at 2020/12/28)

Excepted Result:
Job will be created in pipeline when branch is develop and has been tagged.

Reality:
Job does not created.

CICD yaml:
myjob: only: variables: - ($CI_COMMIT_BRANCH == "develop" && $CI_COMMIT_TAG) script: - echo Hello world

I’m not sure whether it will fix your problem, but I think you can make that configuration a bit more gitlab-like by configuring it like below. At the moment it looks quite like bash syntax and I’m not sure gitlab picks up on that.

myjob:
   only:
     variables:
        - $CI_COMMIT_BRANCH == "develop"
      refs:
        - tags
    script:     - echo Hello world

Or if you don’t want to use the gitlab buid-in refs:

 myjob:
   only:
     variables:
        - $CI_COMMIT_BRANCH == "develop"
        - $CI_COMMIT_TAG
    script:     - echo Hello world

GitLab CI/CD pipeline configuration reference | GitLab also explains that the ‘only’ keyword is an “AND” logical operator, so you won’t transfer your conditions to on OR operator by doing this.

1 Like

Thx, first one not working. But second one work well.

1 Like