I'm trying to run a pipeline where the final stage depends on a previous stage with jobs that are conditional and manual.
I made this example .gitlab-ci.yml to demonstrate the point. I am working with three stages:
stages:
- test
- publish
- create tag
There is one job in the Test stage
# Tests Stage
run tests:
stage: test
script:
- run the tests
Three jobs in the Publish stage, all of which are manual and only exist when certain files have changed
.publish:
stage: publish
script:
- publish x
rules:
- changes:
- $DIR/**/*
when: manual
# Publish Stage
publish package a:
variables:
DIR: a
extends:
- .publish
publish package b:
variables:
DIR: b
extends:
- .publish
publish package c:
variables:
DIR: c
extends:
- .publish
And finally the Create Tag stage, which I only want to run if one of the publish jobs has completed.
# Create Tag Stage
create tag with all packages:
stage: create tag
script:
- git tag
Usually I can use needs
to make the Create Tag job depend on a publishing job. But if, for example, I only make changes in the a/ directory, I will get an error for the following because only "publish package a" exists:
needs:
- "publish package a"
- "publish package b"
- "publish package c"
What I really want is something like
needs:
- "publish package a" if exists
- "publish package b" if exists
- "publish package c" if exists
But there's nothing like this as far as I know. What can I do to run the Create Tags job only when the existing jobs in the Publish stage have completed?