How to Programmatically Construct the URLs for Artifacts

Construct Artifact URLs

In general, we can retrieve the list of URLs to a job's artifacts from our V2 API. However, this is applicable only after the uploading of the artifacts are completed. You can review our article here on how to retrieve the artifacts' URLs after uploading the artifacts.

There may be cases where you would like to pre-determine or construct the URL for an artifact.
In other words, you may want to generate the artifact's URL in advance before the store_artifacts step. In this case, you can use the following URL pattern:${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/<<path to file or folder>>

For instance,

In this example, we had saved a foo.txt file , and can pre-determine the artifact's URL above. We can see that the Job ID, 3df8fe81-1066-4a7b-9843-bad46ff42b65, is populated as the CIRCLE_WORKFLOW_JOB_ID environment variable in our job. Because we are looking at the first node of the job (with parallelism: 2), the CIRCLE_NODE_INDEX value is thus 0.


> Tip: For jobs not using parallelism, the CIRCLE_NODE_INDEX value would always be 0.


Feel free to check out this sample project's config for more details.



The domain where CircleCI artifacts are stored can be subjected to changes. Ideally, we would prefer the V2 API to retrieve the URLs for a job's artifacts, after the store_artifacts steps are run.

Was this article helpful?
6 out of 7 found this helpful



Article is closed for comments.