2

I have two jobs in my gitlab ci pipeline 'job a' and 'job b'. I want only 'job a' to run if variable x is provided and run 'job b' if variable b isn't provided. Something like this.

job a:
  rule:
    - if: variable X is provided
  script:
    - do something

job b:
  rule:
    - if: variable X is not provided
  script:
    - do something

1 Answer 1

2

If you are OK with considering an empty variable value equivalent to it not being "provided", you can do this:

if: $x == ''

for "not provided" and

if: $x != ''

for "provided".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.