How to Find "hold" Step Approver in a Workflow?

 

If you are looking for the information such as name, login ID, etc. of the user who approved the hold step in a workflow, then you can use API endpoints. 

It is a 2 step process and you will have to call 2 different API endpoints for this. 

Follow the below steps:

1. Get the analytics-id of the approver by using Get a workflow's jobs API endpoint. Below is an example.

curl -X GET https://circleci.com/api/v2/workflow/{id}/job -u $CIRCLECI_TOKEN:

Sample output:


"name" : "hold",
"project_slug" : "gh/<org>/<project>",
"approved_by" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"type" : "approval",
"status" : "success",

In the above output, approved_by will contain the analytics-id of the user.

2. Now see the user information with analytics-id using User Information endpoint.

curl -X GET https://circleci.com/api/v2/user/{id} -u $CIRCLECI_TOKEN:

Sample output:


{
"name" : "User Name",
"login" : "login_info",
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}

Note: $CIRCLECI_TOKEN is a variable for a personal API token.

You can use the above API endpoints in your script and get the desired information. Happy building!

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

Comments

0 comments

Article is closed for comments.