Use an artifact from a project, in a different project's CI

ProjectA has created an artifact, projectB needs this artifact to compile. How do you implement retrieving projectA’s artifact in the gitlab-ci.ymal for projectB?

Thanks in advance


Looks like it isn’t possible yet, but there’s an open feature request here. Seems to be a popular idea!

For us, we’ve cheated and used Docker images. It compiles the file into a new Docker container and pushes that to the registry, and then we can import that for multiple other projects. It suits our workflow well because we don’t compile “ProjectA” very often. For your situation it could add a lengthy compile time to your workflow, so it may not work as well for you.

I’d recommend adding a +1 to the above issue though, and subscribe to get updated if it’s implemented.

Thanks Chris.
I see that there is an API call to get an artifact from a repository, but I don’t know how to use it. I have been in windows to long!.

1 Like

Yeah, it looks a bit messy. Seems like you’d need to get a list of the latest builds for a project (so you can obtain the build_id), and then use that to pull the latest artifacts.
(Additional verification would be needed here, such as skipping any builds which have failed).

It does seem possible though. Not sure what language you’re working with so I’m not sure of the best way to interact with the API.

The advantage of the Docker workaround is we only push to the “latest” branch if the build and tests completed successfully, so I can mess around with the project without it affecting anything which has to actually use it as a dependency.

Until there is an easier method, I decided on pushing the required dll’s to a local nugget server (done in the ci ymal for the dll build). Then add the dll’s using nugget, to the project that requires them. This way when I run nugget restore in the ci ymal, the latest built dll’s will be pulled and used. I think this is the easiest way to attack the problem for a windows, visual studio, c#, WPF, and desktop application.



Do anyone knows if there is an easier way to download artifacts from different project, other than described by chrisatomix 3 years ago?

The use case is:

project A is publishing artifact:

name: “artifact-${CI_COMMIT_SHORT_SHA}.tar”

project B would like to download artifact for specific commit, without knowing JOB_ID that was used to build artifact-${CI_COMMIT_SHORT_SHA}.tar

So far I found a way to download latest artifact, without providing JOB_ID.
Sometimes I need to reuse already builded artifact, and I think building it again it is a waste of time


I just found an answer, so if anyone had similar issue:

Below url will download most recent artifact for master branch

but we can change branch to CI_COMMIT_SHORT_SHA and download artifact for specific commit

Which GitLab API is this (link to page please) I’ve been trying this against a locally hosted GitLab system (12.7) and cannot make it work.

1 Like

I’m working now on retrieving artifacts between jobs.
I think it works only for public projects.
see doc here
source answer here
Note: between jobs better using cache instead artifacts