pEpe
pEpe

Reputation: 51

Gitlab-CI rule which compare variable to string of variables

In gitlab-ci, I would like to trigger job only if $CI_COMMIT_TAG matches string which is made of two variables.

Example:

job1:
  variables:
    APP="my-app1"
    APP_VERSION="1.0.0"

  script:
    - some_cmd

  rules:
    - if: $CI_COMMIT_TAG == "$APP-APP_VERSION"

My point is that I use templates, and the rule should not be specific just for a one job, but for all jobs - every job has a unique values in variables ($APP and $APP_VERSION).

So the pipeline should trigger on git tag action and only specific job. But it does not work and I'm stuck...

Is there any solution to evaluate those variables values?

Upvotes: 2

Views: 1669

Answers (1)

mpolitze
mpolitze

Reputation: 136

Not sure if one of the comments solved your issue, but you could also introduce an intermediate variable

variables:
  APP_WITH_APPVERSION: $APP-$APP_VERSION
rules:
    - if: $CI_COMMIT_TAG == "$APP_WITH_APPVERSION"

Upvotes: 0

Related Questions