You can use the CircleCI V2 API to get job details.
Instructions
Using a curl GET request as shown below you will need to replace the project-slug which is your VCS information in the example below this is CircleCI-Public/api-preview-docs and the job number. You will also need to include a form of authorization which can be an api_key_header basic_auth or an api_key_query. A guide can be found under additional resources for utilizing basic authorization.
curl --request GET \ --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123 \ --header 'authorization: Basic REPLACE_BASIC_AUTH'
Outcome
You will retrieve the data for the job. Example output:
{
"web_url": "string",
"project": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"slug": "gh/CircleCI-Public/api-preview-docs",
"name": "api-preview-docs",
"external_url": "https://github.com/CircleCI-Public/api-preview-docs"
},
"parallel_runs": [
{
"index": 0,
"status": "string"
}
],
"started_at": "2019-08-24T14:15:22Z",
"latest_workflow": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "build-and-test"
},
"name": "string",
"executor": {
"resource_class": "string",
"type": "string"
},
"parallelism": 0,
"status": "success",
"number": 1,
"pipeline": {
"id": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"duration": 0,
"created_at": "2019-08-24T14:15:22Z",
"messages": [
{
"type": "string",
"message": "string",
"reason": "string"
}
],
"contexts": [
{
"name": "string"
}
],
"organization": {
"name": "string"
},
"queued_at": "2019-08-24T14:15:22Z",
"stopped_at": "2019-08-24T14:15:22Z"
}
Additional Resources
A link to the API can be found here: https://circleci.com/docs/api/v2/index.html#tag/Job/operation/getJobDetails
A link to utilizing authorization can be found here: https://support.circleci.com/hc/en-us/articles/360052405651-Utilizing-Basic-Authorization-in-CircleCI-API-Calls
Comments
Article is closed for comments.