Hi,
I have 2 jobs in my .gitlab-ci.yml, the first is build and the second is deploy.
I’ve defined them in stages:
stages:
- build
- deploy
build:
stage: build
(...build job...)
artifacts:
name: "${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}_${CI_JOB_ID}"
paths:
- ./
expire_in: 1 week
deploy:
script:
(...launches a docker worker which triggers an Ansible playbook)
I checked that the artifact is correctly passed from build to deploy. However, in the Ansible playbook running in the Docker worker and on my server, I generally get the artifact from the previous job. I’m getting it through:
https://gitlab.com/api/v4/projects/MY_PROJECT_NUMBER/jobs/artifacts/MY_BRANCH/download?job=build
Is there a delay or something, before the artifact becomes available for download through the API ? In the Gitlab.com GUI, I can download the build in the correct newest version, but for the API, I usually have to wait or modify the code to trigger a new pipeline.
Thanks !!!
I have the same problem. It seems the artifacts become available through the API only when the pipeline finished.
1 Like
In fact this API endpoint only gives you the artifact from the latest successful whole pipeline run.
So if like me you have a deploy job in your pipeline, in which you are calling the artifact, it will be the one from the previous sucessfull whole pipeline run.
If for example you have a pipeline of 2 jobs : build and deploy, if build breaks any time, then the pipeline will be considered as failed, and when you fix the build, the deploy will get the artifact from the latest full pipeline which is not interesting because it will always be the old one.
I fixed this by using a different approach to pass the job ID from job build to job deploy, and getting the artifact from the build job ID. I wrote it somewhere here, just browse my profile.
I found your solution and it works, thank you !
1 Like
Hi Thomren, sorry to jump in on the old topic. I do have the same problem with Gitlab 15.1.
When I try to find the solution from Guillaume on his profile, I could not find it.
Would you share the solution in here?