Hi @nroose,
This can be done by getting the workflow id from the environment variable CIRCLE_WORKFLOW_ID and passing that to the following API endpoint:
Sample api call using curl:
PIPELINE_NUMBER=$(curl --request GET \
--url 'https://circleci.com/api/v2/workflow/workflowidgoeshere' \
--header "circle-token: $CIRCLECI_TOKEN" | jq '.pipeline_number')
The pipeline number will be returned. Here is an example json response:
{
"pipeline_id" : "1ac1943v-a2f5-4fe1-82ff-f39d899vscf5a",
"id" : "b8b116f6-911c-4g1c-bf17-0fd4gbde7c12",
"name" : "build_and_test",
"project_slug" : "gh/test-org/test-project",
"status" : "failed",
"started_by" : "2191g76e-87df-3v32-a4adv-371e649sdfg8",
"pipeline_number" : 1276,
"created_at" : "2022-07-16T18:18:20Z",
"stopped_at" : "2022-07-16T18:22:21Z"
}
After getting the pipeline number, you could construct a url using the envars CIRCLE_PROJECT_REPONAME and CIRCLE_PROJECT_USERNAME, or just hard coding the project url part.