Retrieve parent artifact in triggered child does not work
Summary
This process is described and used here. My example below should be the same as the one in this piece of doc.
When triggering a child pipeline, the parent artifacts cannot be retrieved has they are found to be expired/erased. Even tho the pipeline is and job name are correct
The child jobs purpose is explianed here:
-
test 1
: Just test if thePARENT_PIPELINE_ID
is set correctly✔ -
test 2
: Test that the pipelines are pass from parent.❌ -
test 3
: Test theneeds
with a raw pipeline id. Set to the value i suppose the pipeline will be. The id is the right one but same error.❌ -
test 4
: Test another syntax (found here). Works as a workaround
Additional infos:
- As shown in the test 1 output logs below, the variable
PARENT_PIPELINE_ID
is set correctly when the job does not requires artifacts. - Also in the yaml samples you can see the referenced job for the artifacts is
generate
wich correspond to an existing job. - When checking the job with this name in the pipeline with this id I can see it has artifacts.
Steps to reproduce
.gitlab-ci.yml
I'm using this two yaml
parent
stages:
- pre build
- trigger childs
- publish
.on_package: &on_package
only:
- master
- tags
########################################
generate:
stage: pre build
<<: *on_package
script:
- if [[ -z $CI_COMMIT_TAG ]];
then PLAXDMIN_VERSION="v-$(date +%Y%m%d%H%M)-alpha";
else PLAXDMIN_VERSION=${CI_COMMIT_TAG};
fi
- echo ${PLAXDMIN_VERSION}
- echo ${PLAXDMIN_VERSION} >> ./version
artifacts:
paths: [ version ]
expire_in: 30 days
.buil child: &build_child
stage: trigger childs
<<: *on_package
trigger:
project: plaxdmin/api
strategy: depend
variables:
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
trigger api:
<<: *build_child
trigger:
project: plaxdmin/api
strategy: depend
build and publish dockerfile:
stage: publish
<<: *on_package
script:
- echo ${PLAXDMIN_VERSION}
child
stages:
- publish
test 1:
stage: publish
only:
- pipelines
script:
- echo ${PARENT_PIPELINE_ID}
- ls -al .
test 2:
stage: publish
only:
- pipelines
script:
- echo ${PARENT_PIPELINE_ID}
- ls -al .
needs:
- pipeline: $PARENT_PIPELINE_ID
job: generate
test 3:
stage: publish
only:
- pipelines
script:
- echo ${PARENT_PIPELINE_ID}
- ls -al .
needs:
- pipeline: "218"
job: generate
test 4:
stage: publish
only:
- pipelines
script:
- echo ${PARENT_PIPELINE_ID}
- ls -al .
needs:
- project: plaxdmin/meta
job: generate
ref: master
artifacts: true
Actual behavior
When the child pipeline runs it fails with the following error (he does not even start):
This job depends on other jobs with expired/erased artifacts: Please refer to https://docs.gitlab.com/ee/ci/yaml/README.html#dependencies
Expected behavior
The job should run having the artifacts set
Relevant logs and/or screenshots
job log
test 1 logs
$ echo ${PARENT_PIPELINE_ID}
209
Environment description
config.toml contents
[[runners]]
name = "Runner 19"
url = "https://gitlab.vba.ovh/"
token = "ARANDOMSTRING"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "docker:19"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
Used GitLab Runner version
Version: 13.8.0
Git revision: 775dd39d
Git branch: 13-8-stable
GO version: go1.13.8
Built: 2021-01-20T13:32:47+0000
OS/Arch: linux/amd64
Edited by Nindouja