You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: jekyll/_cci2/workflows.md
+49-24Lines changed: 49 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -150,32 +150,54 @@ See the [Sample Fan-in/Fan-out Workflow config](https://github.com/CircleCI-Publ
150
150
151
151
## Holding a Workflow for a Manual Approval
152
152
153
-
Workflows may be configured to wait for manual approval of a job before continuing by using the `type: approval` key. Anyone who has push access to the repository can click the Approval button to continue the workflow.
153
+
Workflows can be configured to wait for manual approval of a job before
154
+
continuing to the next job. Anyone who has push access to the repository can click the Approval button to continue the workflow.
155
+
To do this, add a job to the `jobs` list with the
156
+
key `type: approval`. Let's look at a commented config example.
154
157
155
-
The `approval` job is a special job type that is **only** added to jobs under the `workflow` key. This enables you to configure a job with `type: approval` in the workflow before a set of jobs that must all wait for manual approval. Jobs run in the order defined until the workflow processes a job with the `type: approval` key followed by a job on which it depends as in the following `config.yml` example:
158
+
```yaml
159
+
# ...
160
+
# << Your config for the build, test1, test2, and deploy jobs >>
161
+
# ...
156
162
157
-
```
158
163
workflows:
159
164
version: 2
160
165
build-test-and-approval-deploy:
161
166
jobs:
162
-
- build
163
-
- test1:
164
-
requires:
167
+
- build # your custom job from your config, that builds your code
168
+
- test1: # your custom job; runs test suite 1
169
+
requires: # test1 will not run until the `build` job is completed.
165
170
- build
166
-
- test2:
167
-
requires:
171
+
- test2: # another custom job; runs test suite 2,
172
+
requires: # test2 is dependent on the succes of job `test1`
168
173
- test1
169
-
- hold:
170
-
type: approval
171
-
requires:
174
+
- hold: # <<< A job that will require manual approval in the CircleCI web application.
175
+
type: approval # <<< This key-value pair will set your workflow to a status of "On Hold"
176
+
requires: # We only run the "hold" job when test2 has succeeded
172
177
- test2
178
+
# On approval of the `hold` job, any successive job that requires the `hold` job will run.
179
+
# In this case, a user is manually triggering the deploy job.
173
180
- deploy:
174
181
requires:
175
182
- hold
176
183
```
177
184
178
-
In this example, the `deploy:` job will not run until you click the `hold` job in the Workflows page of the CircleCI app and then click Approve. Notice that the `hold` job must have a unique name that is not used by any other job. The workflow will wait with the status of On Hold until you click the job and Approve. After you approve the job with `type: approval`, the jobs which require the approval job will start. In the example above, the purpose is to wait for approval to begin deployment. To configure this behavior, the `hold` job must be `type: approval` and the `deploy` job must require `hold`.
185
+
The outcome of the above example is that the `deploy:` job will not run until
186
+
you click the `hold` job in the Workflows page of the CircleCI app and then
187
+
click Approve. In this example the purpose of the `hold` job is to wait for
188
+
approval to begin deployment.
189
+
190
+
Some things to keep in mind when using manual approval in a workflow:
191
+
192
+
-`approval` is a special job type that is **only** available to jobs under the `workflow` key
193
+
- The `hold` job must be a unique name not used by any other job.
194
+
- that is, your custom configured jobs, such as `build` or `test1` in the
195
+
example above wouldn't be given a `type: approval` key.
196
+
- The name of the job to hold is arbitrary - it could be `wait` or `pause`, for example,
197
+
as long as the job has a `type: approval` key in it.
198
+
- All jobs that are to run after a manually approved job _must_`require:` the
199
+
name of that job. Refer to the `deploy:` job in the above example.
200
+
- Jobs run in the order defined until the workflow processes a job with the `type: approval` key followed by a job on which it depends.
179
201
180
202
The following screenshots show a workflow on hold waiting for approval of the `request-testing` job:
181
203
@@ -449,34 +471,37 @@ To persist data from a job and make it available to other jobs, configure the jo
449
471
450
472
Configure a job to get saved data by configuring the `attach_workspace` key. The following `config.yml` file defines two jobs where the `downstream` job uses the artifact of the `flow` job. The workflow configuration is se
10000
quential, so that `downstream` requires `flow` to finish before it can start.
451
473
452
-
```
453
-
# The following stanza defines a map named defaults with a variable that may be inserted using the YAML merge (<<: *) key
454
-
# later in the file to save some typing. See http://yaml.org/type/merge.html for details.
474
+
```yaml
475
+
# Note that the following stanza uses CircleCI 2.1 to make use of a Reusable Executor
476
+
# This allows defining a docker image to reuse across jobs.
477
+
# visit https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors to learn more.
0 commit comments