Situation
Consider the following .gitlab-ci.yml
example:
build:
stage: build
script: echo "Building..."
build-doc:
stage: build
when: manual
script:
- echo "Building doc..."
- echo "build result" > output.txt
artifacts:
name: "%CI_BUILD_NAME%_%CI_BUILD_ID%"
expire_in: 1 week
paths:
- "output.txt"
deploy-doc:
stage: deploy
only:
- master
dependencies:
- build-doc
script:
- echo "Deploying doc..."
- type output.txt
Result
The result of this pipeline on the master
branch is:
The log of the deploy-doc
job says:
$ echo "Deploying doc..."
"Deploying doc..."
$ type output.txt
The system cannot find the file specified.
ERROR: Build failed: exit status 1
Conclusion
Even if the deploy-doc
has explicitly a dependency on the manual build-doc
job artifact, the build-doc
don't get triggered leading to the a fail of the deploy-doc
job.
Question
How can I implement this behaviour correctly? Namely, having a manual job which get triggered when an automatic job has dependencies on him?
Context
I only want to automatically build and deploy the doc on the master
branch, the other branches can only build the doc manually to download the generated doc.
Solution
In addendum to the accepted answer, see my own answer below.