Download all artifacts for a build on CircleCI

Sometimes it’s useful to get all the artifact files for a build. Here’s how you can do that with 3 lines of bash and no dependencies. This works with both CircleCI 1.0 and 2.0.

First create an API token via our UI: Go to ‘Account Settings > API Tokens’, create a new token and copy it.

CD to a directory where you would like the artifacts files to be. Then run:

export CIRCLE_TOKEN='?circle-token=:your_token'

curl$CIRCLE_TOKEN | grep -o 'https://[^"]*' > artifacts.txt

<artifacts.txt xargs -P4 -I % wget %$CIRCLE_TOKEN

Note 1: Replace all the variables above that start with a : with real values for your project (don’t include the colon).

Note 2: :vcs-type will be github or bitbucket.

Note 3: The xargs command runs 4 processes to download files in parallel. You can adjust this value to your needs.

Explanation: The line beginning curl fetches all the artifacts details for a build - we then pipe this through the grep command to extract just the URLs. The results are saved to a file artifacts.txt. Then xargs reads in that file and downloads each artifact file.


the last command should be

<artifacts.txt xargs -P4 -I % wget %?circle-token=$CIRCLE_TOKEN

Took some time for me to realize this and fix the issue

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.