I would like to add a job to a pipeline in Gitlab, but only if a tool, e.g. Maven, exits with exit code 0.
For example, I would like to run the job for integration tests only if a given profile exists.
Currently I run always the job, but skip the call to Maven if the profile does not exists. Unfortunately my current approach adds the job to the pipeline and the viewer of the pipeline might think, that the job as been executed.
integration-test-job:
stage: build
script:
- |
if mvn help:all-profiles | grep "Profile Id: IT" 2>&- 1>&-;
then
mvn -P IT clean install
fi
Does someone have a better solution?