I can’t figure out how Gitlab deals with artifacts between different pipelines. I am trying to set up a pipeline in which commits lead to builds and tests, after which a deployment can be triggered by a pipeline trigger.
I have a single project with a .gitlab-ci.yml file, in which I have defined 3 stages [in pseudo-yaml]:
stages: - build - test - deploy
My build stage packages some python code, sql files, and config files in a dir, and stores it in an artifact.
build: stage: build script: - mkdir target - python setup.py [foo] --dist_dir=target - cp -r sqlscripts target - cp -r configfiles target artifacts: name: "build" paths: - target
The test stage tests the code but doesn’t do anything special with the artifact. The build and test stage always run for commits on a branch.
Next I have the deploy stage. This stage does not run on commits, but on triggers only.
deploy: stage: deploy dependencies: - build script: # Deploy to the unit. - deploy.sh only: - triggers
- I get two different pipelines. I wouldn’t expect this based on my ‘stages’ definition.
- I cannot find the build artifact. I think this is because I have two different pipelines. How do I get the artifact available in the deploy job?
In order to get the build artifact, I have tried using the artifact API, adding the following lines to the deploy script entry:
- 'curl --location --output artifacts.zip "https://gitlab.com/api/v4/projects/my-id/jobs/artifacts/my-ref/download?job=build&job_token=$CI_JOB_TOKEN"' - 'unzip artifacts.zip'
Unfortunately, this artifacts.zip file is not a zip file. Instead, curl gives a 404: project not found error. Is the CI_JOB_TOKEN only valid for Gitlab Premium?
How do I use the artifact from the build stage in my triggered deploy stage?