Skip to content

Commit 99c047a

Browse files
authored
Adding information on how to identify job approver (#9374)
* Adding content on how to identify job approver * Adding code snippets for API calls * Adding instructions on how to get th workflow ID * Adding short intro * Updating obsolete xref
1 parent e4510f1 commit 99c047a

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

jekyll/_cci2/workflows.adoc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,80 @@ curl --request POST \
277277
--header "Circle-Token: ${CIRCLE_TOKEN}" \
278278
--header 'content-type: application/json' \
279279
----
280+
--
281+
282+
283+
=== Identify the user who approved a job
284+
285+
To identify the user who approved a job, you can use the CircleCI web app or the API.
286+
287+
[.tab.identify.CircleCI_web_app]
288+
--
289+
* If the user signed up via GitHub, the (non-clickable) avatar of the GitHub user appears next to the approval job. Hovering over that avatar brings up a tooltip with the user's name as specified in their GitHub/Bitbucket account settings.
290+
291+
* If the user signed up via email, the anonymous avatar appears next to the approval job; hovering over that avatar brings up a tooltip with the user's email address.
292+
--
293+
294+
[.tab.identify.API]
295+
--
296+
. Set up your API authentication. Steps are available in the xref:api-developers-guide#add-an-api-token[API developers guide].
297+
. You need the workflow ID so you can use the link:https://circleci.com/docs/api/v2/index.html#operation/listWorkflowJobs[get a workflow's jobs] endpoint to get the user ID. You can get the workflow ID using xref:variables#[pipeline values or environment variables], or by xref:outbound-webhooks#[receiving webhooks] or link:https://circleci.com/docs/api/v2/index.html#tag/Pipeline/operation/listWorkflowsByPipelineId[polling the API]
298+
+
299+
[,shell]
300+
----
301+
curl --request GET \
302+
--url https://circleci.com/api/v2/workflow/<workflow-ID>/job \
303+
--header "Circle-Token: ${CIRCLE_TOKEN}" \
304+
--header 'content-type: application/json' \
305+
----
306+
307+
. In the JSON response, take note of the value associated with the `approved_by` key. This is the user ID of the user who approved the job.
308+
+
309+
[,json]
310+
----
311+
"name" : "hold",
312+
"project_slug" : "gh/<org>/<project>",
313+
"approved_by" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
314+
"type" : "approval",
315+
"status" : "success",
316+
----
317+
318+
. Then use the link:https://circleci.com/docs/api/v2/index.html#operation/getUser[user information] endpoint to get the username or email address.
319+
+
320+
[,shell]
321+
----
322+
curl --request GET \
323+
--url https://circleci.com/api/v2/user/<user-ID> \
324+
--header "Circle-Token: ${CIRCLE_TOKEN}" \
325+
--header 'content-type: application/json' \
326+
----
327+
328+
** If the user who approved the job signed up via GitHub or Bitbucket, the response from the user information endpoint will have the following format:
329+
+
330+
[,json]
331+
----
332+
{
333+
"name" : "User’s name as specified in their VCS account settings",
334+
"login" : "VCS username",
335+
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
336+
}
337+
----
338+
339+
** If the user who approved the job signed up via email, the response from the user information endpoint will have the following format:
340+
+
341+
[,json]
342+
----
343+
{
344+
"name" : "Email address",
345+
"login" : "Email address",
346+
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
347+
}
348+
----
349+
350+
TIP: You can find detailed instructions in link:https://support.circleci.com/hc/en-us/articles/360044820493-How-to-Find-hold-Step-Approver-in-a-Workflow[this support article]
351+
352+
353+
280354
--
281355

282356
=== Cancel a job

0 commit comments

Comments
 (0)