Retrieving job step output via the API

Overview

CircleCI provides a v1.1 API endpoint to retrieve details about individual job steps, including their output. This is useful for debugging or auditing your workflows. By querying this API, you can access a list of steps for a given job and their respective output URLs.

This guide demonstrates how to retrieve job step outputs using curl and jq.

Using curl and jq to retrieve step outputs

To get the step outputs for a specific job, you can use the following API endpoint:

https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/:build_num

Here’s a simple example to retrieve the step outputs:

curl --request GET \
--url https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/:build_num \
--header "Circle-Token: ${MY_API_KEY}" |
jq -r '.steps[] | "\(.actions[0].output_url)\t\(.name)"'

Explanation

:vcs-type: Your version control system type (e.g., gh for GitHub or bb for Bitbucket).

:username: Your username or organization name.

:project: The project/repository name.

:build_num: The specific build number you want to query.

${MY_API_KEY}: Your CircleCI API token.

The jq command parses the JSON response to extract the output_url for each step and its corresponding name. The output URL itself is a pre-signed URL and requires no subsequent authentication.

References

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.