Hello!
I’m new to GitLab CI/CD.
I wish to have a job inside PROJECT_2 access artifacts from another job on a different project - PROJECT_1. I have added a snippet below.
PROJECT_1:
.gitlab-ci.yml
---
job1:
---
artifacts:
paths:
- dir1
PROJECT_2:
.gitlab-ci.yml
---
job2:
--
needs:
- project: PROJECT_1
job: job1
ref: master
artifacts: true
This code above works fine. I would like to know if we can have the entries under needs
attribute like project
, job
and ref
to be dynamic? Can I pass an env var, say PROJ_DEP
and set it to PROJECT_1
when I kick off a pipeline and have the needs
attribute expand them correctly?
I have tried passing a variable for components inside needs
attribute like shown below.
job2:
--
needs:
- project: $PROJ_DEP # linux runner
job: $JOB_DEP
ref: $REF_DEP
artifacts: true
But, I encounter the following error.
This job depends on other jobs with expired/erased artifacts:
Please refer to CI/CD YAML syntax reference | GitLab
I have confirmed that the job does have artifacts available and as I mentioned above, it works fine if I don’t use the variables.
I’m using GitLab v13.3.6-ee and Runner v13.3.1
Thanks.