Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
continuation: circleci/continuation@1.1.0
Use continuation
elements in your existing workflows and jobs.
Utilize the "continue" job to specify which configuration file to run next.
1
2
3
4
5
6
7
8
9
version: '2.1'
setup: true
orbs:
continuation: circleci/continuation@0.5.0
workflows:
use-my-orb:
jobs:
- continuation/continue:
configuration_path: .circleci/continue_config.yml
Utilize the "continue" job to specify which configuration file to run next and add additional parameters.
1
2
3
4
5
6
7
8
9
10
version: '2.1'
setup: true
orbs:
continuation: circleci/continuation@0.5.0
workflows:
use-my-orb:
jobs:
- continuation/continue:
configuration_path: .circleci/continue_config.yml
parameters: '{"image-tag":"current"}'
Make a request to the API to continue the pipeline.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
checkout | Whether to run an optional checkout step before continuing | No | true | boolean |
circleci_domain | The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users) | No | circleci.com | string |
circleci_ip_ranges | Enables jobs to go through a set of well-defined IP address ranges. | No | false | boolean |
configuration_path | The path to the configuration that will be passed to the continue API | Yes | - | string |
parameters | The parameters used for the pipeline. This can either be a JSON object containing parameters or a path to a file containing a JSON object with parameters | No | '{}' | string |
resource_class | Resource class to use | No | small | string |
workspace_path | Path to attach the workspace to | No | '' | string |
Makes a post request to https://circleci.com/api/v2/pipeline/continue to continue a setup workflow.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
circleci_domain | The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users) | No | circleci.com | string |
configuration_path | The path to the configuration that will be passed to the continue API | Yes | - | string |
parameters | The parameters used for the pipeline. This can either be a JSON object containing parameters or a path to a file containing a JSON object with parameters | No | '{}' | string |
when | Specify when to enable or disable this command | No | on_success | enum |
Makes a post request to https://circleci.com/api/v2/pipeline/continue with an empty config to advance the pipeline, but not execute any further workflows, preventing other continuations.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
circleci_domain | The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users) | No | circleci.com | string |
The executor for continuations
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
tag | Pick a specific circleci/base image variant: https://hub.docker.com/r/cimg/base/tags
| No | stable | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Utilize Setup Workflows and the Continuation orb to easily construct dynamic and multi-config pipelines.
display:
home_url: https://circleci.com/docs/2.0/dynamic-config/
source_url: https://github.com/CircleCI-Public/continuation-orb/
commands:
continue:
description: |
Makes a post request to https://circleci.com/api/v2/pipeline/continue to continue a setup workflow.
parameters:
circleci_domain:
default: circleci.com
description: The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users)
type: string
configuration_path:
description: The path to the configuration that will be passed to the continue API
type: string
parameters:
default: '{}'
description: The parameters used for the pipeline. This can either be a JSON object containing parameters or a path to a file containing a JSON object with parameters
type: string
when:
default: on_success
description: Specify when to enable or disable this command
enum:
- on_success
- on_fail
- always
type: enum
steps:
- run:
command: |
#!/bin/sh
set -e
if [ -z "${CIRCLE_CONTINUATION_KEY}" ]; then
echo "CIRCLE_CONTINUATION_KEY is required. Make sure setup workflows are enabled."
exit 1
fi
if [ -z "${CONFIG_PATH}" ]; then
echo "CONFIG_PATH is required."
exit 1
fi
if ! which curl > /dev/null; then
echo "curl is required to use this command"
exit 1
fi
if ! which jq > /dev/null; then
echo "jq is required to use this command"
exit 1
fi
PARAMS=$([ -f "$PARAMETERS" ] && cat "$PARAMETERS" || echo "$PARAMETERS")
COMMAND=$(echo "$PARAMS" | jq . >/dev/null 2>&1)
if ! $COMMAND; then
echo "PARAMETERS aren't valid json"
exit 1
fi
mkdir -p /tmp/circleci
rm -rf /tmp/circleci/continue_post.json
# Escape the config as a JSON string.
jq -Rs '.' "$CONFIG_PATH" > /tmp/circleci/config-string.json
jq -n \
--arg continuation "$CIRCLE_CONTINUATION_KEY" \
--arg params "$PARAMS" \
--slurpfile config /tmp/circleci/config-string.json \
'{"continuation-key": $continuation, "configuration": $config|join("\n"), "parameters": $params|fromjson}' > /tmp/circleci/continue_post.json
cat /tmp/circleci/continue_post.json
[ "$(curl \
-o /dev/stderr \
-w '%{http_code}' \
-XPOST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data @/tmp/circleci/continue_post.json \
"https://${CIRCLECI_DOMAIN}/api/v2/pipeline/continue")" \
-eq 200 ]
environment:
CIRCLECI_DOMAIN: <<parameters.circleci_domain>>
CONFIG_PATH: <<parameters.configuration_path>>
PARAMETERS: <<parameters.parameters>>
name: Continue Pipeline
when: <<parameters.when>>
finish:
description: |
Makes a post request to https://circleci.com/api/v2/pipeline/continue with an empty config to advance the pipeline, but not execute any further workflows, preventing other continuations.
parameters:
circleci_domain:
default: circleci.com
description: The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users)
type: string
steps:
- run:
command: |
if ! which curl > /dev/null; then
echo "curl is required to use this command"
exit 1
fi
if ! which jq > /dev/null; then
echo "jq is required to use this command"
exit 1
fi
JSON_BODY=$( jq -n \
--arg continuation "$CIRCLE_CONTINUATION_KEY" \
'{"continuation-key": $continuation, "configuration": "{version: 2, jobs: {}, workflows: {version: 2}}", parameters: {}}'
)
echo "$JSON_BODY"
[[ $(curl \
-o /dev/stderr \
-w '%{http_code}' \
-XPOST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data "${JSON_BODY}" \
"https://${CIRCLECI_DOMAIN}/api/v2/pipeline/continue") \
-eq 200 ]]
environment:
CIRCLECI_DOMAIN: <<parameters.circleci_domain>>
name: Finish Pipeline
executors:
default:
description: |
The executor for continuations
docker:
- image: cimg/base:<<parameters.tag>>
parameters:
tag:
default: stable
description: |
Pick a specific circleci/base image variant: https://hub.docker.com/r/cimg/base/tags
type: string
jobs:
continue:
circleci_ip_ranges: << parameters.circleci_ip_ranges >>
description: |
Make a request to the API to continue the pipeline.
executor: default
parameters:
checkout:
default: true
description: Whether to run an optional checkout step before continuing
type: boolean
circleci_domain:
default: circleci.com
description: The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users)
type: string
circleci_ip_ranges:
default: false
description: Enables jobs to go through a set of well-defined IP address ranges.
type: boolean
configuration_path:
description: The path to the configuration that will be passed to the continue API
type: string
parameters:
default: '{}'
description: The parameters used for the pipeline. This can either be a JSON object containing parameters or a path to a file containing a JSON object with parameters
type: string
resource_class:
default: small
description: Resource class to use
type: string
workspace_path:
default: ""
description: Path to attach the workspace to
type: string
resource_class: << parameters.resource_class >>
steps:
- when:
condition:
equal:
- true
- << parameters.checkout >>
steps:
- checkout
- when:
condition:
not:
equal:
- ""
- << parameters.workspace_path >>
steps:
- attach_workspace:
at: << parameters.workspace_path >>
- continue:
circleci_domain: << parameters.circleci_domain >>
configuration_path: << parameters.configuration_path >>
parameters: << parameters.parameters >>
examples:
continue_pipeline:
description: |
Utilize the "continue" job to specify which configuration file to run next.
usage:
version: "2.1"
setup: true
orbs:
continuation: circleci/continuation@0.5.0
workflows:
use-my-orb:
jobs:
- continuation/continue:
configuration_path: .circleci/continue_config.yml
continue_pipeline_with_parameters:
description: |
Utilize the "continue" job to specify which configuration file to run next and add additional parameters.
usage:
version: "2.1"
setup: true
orbs:
continuation: circleci/continuation@0.5.0
workflows:
use-my-orb:
jobs:
- continuation/continue:
configuration_path: .circleci/continue_config.yml
parameters: '{"image-tag":"current"}'