patternMinor
Run GitLab job only if variable is provided
Viewed 0 times
gitlabprovidedonlyvariablejobrun
Problem
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.
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 somethingSolution
If you are OK with considering an empty variable value equivalent to it not being "provided", you can do this:
for "not provided" and
for "provided".
if: $x == ''
for "not provided" and
if: $x != ''
for "provided".
Context
StackExchange DevOps Q#17469, answer score: 2
Revisions (0)
No revisions yet.