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.

  stage: build
    - |
      if mvn help:all-profiles | grep "Profile Id: IT" 2>&- 1>&-; 
        mvn -P IT clean install

Does someone have a better solution?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.