Reputation: 3623
Just like git push -o ci.skip
can be used to skip all stages, is it possible to also just as easily specify a whitelist of stages to run while pushing?
Currently I have to manually go to gitlab UI after a push and skip the stages that I don't want running. I also have to track stage dependencies manually while doing this.
Can this be done more easily?
Upvotes: 3
Views: 2379
Reputation: 40861
You can set CICD variables with git push options. Therefore, you can use such variables to set whether a job runs or not using only:variables
/except:variables
or rules:
For example:
my_job:
rules:
- if: $MY_VARIABLE_NEVER
when: never
- if: $MY_VARIABLE_ALWAYS
when: always
- when: on_success
# ...
Then you can use the push option to set the variables in your rules:
# excludes my_job from the pipeline
git push -o ci.variable="MY_VARIABLE_NEVER=true"
This can't be applied for an entire stage directly, but you can apply the applicable only:
/except:
or rules:
for each job in the stage you want to control.
Upvotes: 2