Old artifact when getting it via Gitlab API (Gitlab.com)


I have 2 jobs in my .gitlab-ci.yml, the first is build and the second is deploy.
I’ve defined them in stages:

  - build
  - deploy

  stage: build
  (...build job...)
      - ./
      expire_in: 1 week

    (...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:


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 !!!

Up for one hint maybe?

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