Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add all-in-one artifacts download command, per workflow #8979

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions jekyll/_cci2/artifacts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ Similarly, if you want to download the _latest_ artifacts of a build, replace th
curl -H "Circle-Token: <circle-token>" https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/latest/artifacts
----

In some cases, you may need to download all artefacts from an entire workflow in one time. Having the workflow ID, possibly using the URL, you can use:

[,shell]
----
# Set an environment variable for your API token.
export CIRCLE_TOKEN=':your_token'

# `curl` retrieve the list of jobs in the workflow,
# then `jq` lists from the result and filter the job identifiers,
# then `xargs`/`curl` generates the jobs URLs including the jobs identifiers,
# then the result is piped into `grep` to extract the URLs,
# finally, `wget` is used to download the artifacts to the current directory in your terminal.

curl --silent --request GET --url https://circleci.com/api/v2/workflow/:workflow_id/job --header "Circle-Token: $CIRCLE_TOKEN" \
| jq '.items[].job_number' \
| xargs -I {} curl --silent --request GET --url 'https://circleci.com/api/v2/project/:vcs/:org/:project/{}/artifacts' --header "Circle-Token: $CIRCLE_TOKEN" \
| grep -o -E 'https://([^"]*)' \
| wget --verbose --header "Circle-Token: $CIRCLE_TOKEN" --no-verbose --input-file -
----

You can read more about using CircleCI's API to interact with artifacts in our link:https://circleci.com/docs/api/v1/#artifacts[API reference guide].

[.table.table-striped]
Expand Down