'Artifacts are not pulled in a child pipeline
This is my gitlab ci config. In the build stage the application is build in the distfolder, which is stored as an artifact.
The next deploy stage is a trigger to run a child pipeline for the deployment.
But the dist artifacts aren't pulled for the child pipeline, so the child job fails.
- How do I get the
distartifacts in the child job? - Even if the child deploy job fails, the parent pipeline shows a complete pass. I would expect to see, that at least one child has failed.
.gitlab-ci.yml
stages:
- build
- deployment
build:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}
policy: pull
paths:
- node_modules/
artifacts:
when: always
paths:
- deployment.yml
- dist/
script:
- node ./build-app.js # creates dist folder
- node ./generate-pipeline.js # generates deployment.yml
trigger-deploy:
stage: deployment
trigger:
include:
- artifact: deployment.yml
job: build
deployment.yml
stages:
- deploy
app1-deploy:
stage: deploy
script:
- ls dist # fails, as dist folder is not existing
Solution 1:[1]
The 'trigger-deploy' job needs a dependency of the 'build' job, to allow the artifacts to be providable.
To get the parent to fail when the child pipeline fails you'll need to add a strategy to the include strategy: depend. see last example
Solution 2:[2]
needs:pipeline:job
A child pipeline can download artifacts from a job in its parent pipeline or another child pipeline in the same parent-child pipeline hierarchy.
Documented here: https://docs.gitlab.com/ee/ci/yaml/#needspipelinejob
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | szucsz |
