Skip to content

Commit abef5f7

Browse files
Update workflows.adoc (circleci#8955)
* Update workflows.adoc Added the text to include cancelling an approval job. Was not able to an image replacement. * fix tab formatting * update image * remove redundant headers --------- Co-authored-by: Rosie Yohannan <[email protected]>
1 parent e4b8a9a commit abef5f7

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

jekyll/_cci2/workflows.adoc

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,18 @@ See the link:https://github.com/CircleCI-Public/circleci-demo-workflows/tree/fan
154154
[#holding-a-workflow-for-a-manual-approval]
155155
== Hold a workflow for a manual approval
156156

157-
Use an `approval` job to configure a workflow to wait for manual approval before continuing. Anyone who has push access to the repository can approve the job to continue the workflow. Approve either by using the *Approve* button in the CircleCI web app, or via the API.
157+
Use an `approval` job to configure a workflow to wait for manual approval before continuing. Anyone who has push access to the repository can approve the job to continue the workflow or cancel to end the workflow. Approve or Cancel either by using the buttons in the CircleCI web app, or via the API.
158158

159159
Some things to keep in mind when using manual approval in a workflow:
160160

161161
* `approval` is a special job type that is configured when listing jobs under the `workflows` key. You do not need to define an `approval` type job in the `jobs` section of your configuration. If you do configure steps for a job that is given the `approval` type in the workflows section, the steps for that job will not be run. An `approval` job is _only_ used to _hold_ the workflow for approval, not to run any work.
162162
* The `approval` job name must be unique and not used by any other job in your configuration.
163163
* The name of the approval job is arbitrary. For example, an approval job can be named `hold`, `wait`, `pause`, etc.
164164
* All jobs that run _after_ a manual approval job **must** `require` the name of the `approval` job.
165-
* Jobs run in the order defined in the workflow. When the workflow encounters a job with `type: approval`, the workflow pauses until approval is granted. Once approval is granted the workflow continues to process jobs in the order defined in the configuration file.
165+
* Jobs run in the order defined in the workflow.
166+
* When the workflow encounters a job with `type: approval`, the workflow pauses until action is taken to approve or cancel.
167+
* If approval is granted the workflow continues to process jobs in the order defined in the configuration file.
168+
* If cancel is granted the downstream jobs are not run.
166169
* Jobs downstream of an `approval` job can be restricted by adding a xref:contexts#approve-jobs-that-use-restricted-contexts[restricted context] to those downstream jobs.
167170

168171
The following screenshot demonstrates:
@@ -173,7 +176,7 @@ The following screenshot demonstrates:
173176

174177
image::/docs/assets/img/docs/approval-workflow-map.png[A three section image showing workflow map with "Needs approval" job, the approval popup, and the workflow map]
175178

176-
By clicking on the `approval` job's name (`hold`, in the screenshot above), an approval dialog box appears. You can approve or close the popup without approving.
179+
By clicking on the `approval` job's name (`hold`, in the screenshot above), an approval dialog box appears. You can approve, cancel, or close the popup without approving.
177180

178181
=== Configure an approval job
179182

@@ -227,7 +230,30 @@ To approve a job follow these steps:
227230
----
228231
curl --request POST \
229232
--url https://circleci.com/api/v2/workflow/<workflow-ID>/approve/<approval_request_id> \
230-
--header 'authorization: Basic REPLACE_BASIC_AUTH' \
233+
--header "Circle-Token: ${CIRCLE_TOKEN}" \
234+
--header 'content-type: application/json' \
235+
----
236+
--
237+
238+
=== Cancel a job
239+
240+
To Cancel a job follow these steps:
241+
242+
[.tab.cancel.CircleCI_web_app]
243+
--
244+
. Select the `hold` job in the *Workflows* page of the CircleCI web app.
245+
. Select btn:[Cancel].
246+
--
247+
248+
[.tab.cancel.API]
249+
--
250+
. Set up your API authentication. Steps are available in the xref:api-developers-guide#add-an-api-token[API developers guide].
251+
. You need your job ID (which is the job ID for the job requiring approval) to make the API POST request. Depending on your use case, you might be configuring an approval job in a pipeline, or using an external service to approve a job. You can get the required parameters using xref:variables#[pipeline values or environment variables], or by xref:webhooks#[receiving webhooks] or polling the API. To cancel a job, use the link:https://circleci.com/docs/api/v2/index.html#operation/cancelJobByJobID[cancel a job] endpoint, for example:
252+
+
253+
[,shell]
254+
----
255+
curl --request POST \
256+
--url https://circleci.com/api/v2/jobs/<job-ID>/cancel \
231257
--header "Circle-Token: ${CIRCLE_TOKEN}" \
232258
--header 'content-type: application/json' \
233259
----
-14.1 KB
Loading

0 commit comments

Comments
 (0)