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

How to find the user who approved a workflow

You can use the following endpoints and examples to find the user who approved a hold step.

 

Please 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?
4 out of 6 found this helpful

Comments

0 comments

Article is closed for comments.