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:
split-config: bufferings/split-config@0.1.0
Use split-config
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
You can write the split config paths in a file and set it to the config-list-path parameter. Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
config-list-path: .circleci/config-list
You can use regex to specify the split configs. Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
find-config-regex: .*/\.circleci/config\.yml
You can use fixed-config-paths parameter to specify the split configs. Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
1
2
3
4
5
6
7
8
9
10
11
12
version: '2.1'
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
fixed-config-paths: |
./common/.circleci/config.yml
./service1/.circleci/config.yml
./service2/.circleci/config.yml
./service3/.circleci/config.yml
Merge split files and generate configuration
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
config-list-path | A file path to append config paths. Each path in this file should be relative to the working directory.
| No | /tmp/config-list | string |
continuation | Whether to continue the execution with the generated config or not.
| No | true | boolean |
continuation-circleci_domain | The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users)
| No | circleci.com | string |
continuation-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 |
find-config-regex | Regex to find configs from the working directory.
| No | '' | string |
fixed-config-paths | Multiline string of fixed config paths to append. One path for each line. Each path should be relative to the working directory.
| No | '' | string |
generated-config-path | A file path for the generated config file.
| No | /tmp/generated-config.yml | string |
Find configs by regex and append the result to the config list.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
config-list-path | A file path to append config paths. Each path in this file should be relative to the working directory.
| No | /tmp/config-list | string |
find-config-regex | Regex to find configs from the working directory.
| No | '' | string |
Append fixed config paths to the config list.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
config-list-path | A file path to append config paths. Each path in this file should be relative to the working directory.
| No | /tmp/config-list | string |
fixed-config-paths | Multiline string of fixed config paths to append. One path for each line. Each path should be relative to the working directory.
| No | '' | string |
Generate config file from the config list.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
config-list-path | A file path to append config paths. Each path in this file should be relative to the working directory.
| No | /tmp/config-list | string |
generated-config-path | A file path for the generated config file.
| No | /tmp/generated-config.yml | string |
cimg/go image with CUE
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
tag | Pick a specific bufferings/cimg-cue image variant: https://hub.docker.com/r/bufferings/cimg-cue/tags
| No | latest | 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
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/ja/orbs/licensing
version: 2.1
description: |
You can merge split files when CircleCI starts. This Orb uses CUE https://cuelang.org/ to merge the configuration files.
display:
home_url: https://github.com/bufferings/orb-split-config
source_url: https://github.com/bufferings/orb-split-config
orbs:
continuation: circleci/continuation@0.3.1
commands:
append-find-result:
description: |
Find configs by regex and append the result to the config list.
parameters:
config-list-path:
default: /tmp/config-list
description: |
A file path to append config paths. Each path in this file should be relative to the working directory.
type: string
find-config-regex:
default: ""
description: |
Regex to find configs from the working directory.
type: string
steps:
- run:
command: |
#!/bin/bash
find . -type f -regex "${PARAM_FIND_CONFIG_REGEX}" \
-not -regex "\./\.circleci/config\.yml" \
>> "${PARAM_CONFIG_LIST_PATH}"
echo "Config list ==="
cat "${PARAM_CONFIG_LIST_PATH}"
echo
environment:
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
PARAM_FIND_CONFIG_REGEX: <<parameters.find-config-regex>>
name: Append find result
append-fixed-paths:
description: |
Append fixed config paths to the config list.
parameters:
config-list-path:
default: /tmp/config-list
description: |
A file path to append config paths. Each path in this file should be relative to the working directory.
type: string
fixed-config-paths:
default: ""
description: |
Multiline string of fixed config paths to append. One path for each line. Each path should be relative to the working directory.
type: string
steps:
- run:
command: |
#!/bin/bash
echo "${PARAM_FIXED_CONFIG_PATH}" >> "${PARAM_CONFIG_LIST_PATH}"
echo "Config list ==="
cat "${PARAM_CONFIG_LIST_PATH}"
echo
environment:
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
PARAM_FIXED_CONFIG_PATH: <<parameters.fixed-config-paths>>
name: Append fixed paths
generate-config:
description: |
Generate config file from the config list.
parameters:
config-list-path:
default: /tmp/config-list
description: |
A file path to append config paths. Each path in this file should be relative to the working directory.
type: string
generated-config-path:
default: /tmp/generated-config.yml
description: |
A file path for the generated config file.
type: string
steps:
- run:
command: |
#!/bin/bash
echo "Config list ==="
cat "${PARAM_CONFIG_LIST_PATH}"
echo
echo "Generated YAML ==="
cat "${PARAM_CONFIG_LIST_PATH}" \
| awk 'NF {printf "\"%s\" ", $0}' \
| xargs -0 -I {} sh -c 'cue export {} --out yaml' \
| tee "${PARAM_GENERATED_CONFIG_PATH}"
echo
environment:
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
PARAM_GENERATED_CONFIG_PATH: <<parameters.generated-config-path>>
name: Generate config
executors:
default:
description: |
cimg/go image with CUE
docker:
- image: bufferings/cimg-cue:<<parameters.tag>>
parameters:
tag:
default: latest
description: |
Pick a specific bufferings/cimg-cue image variant: https://hub.docker.com/r/bufferings/cimg-cue/tags
type: string
jobs:
generate-config:
description: |
Merge split files and generate configuration
executor: default
parameters:
config-list-path:
default: /tmp/config-list
description: |
A file path to append config paths. Each path in this file should be relative to the working directory.
type: string
continuation:
default: true
description: |
Whether to continue the execution with the generated config or not.
type: boolean
continuation-circleci_domain:
default: circleci.com
description: |
The domain of the CircleCI installation - defaults to circleci.com. (Only necessary for CircleCI Server users)
type: string
continuation-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
find-config-regex:
default: ""
description: |
Regex to find configs from the working directory.
type: string
fixed-config-paths:
default: ""
description: |
Multiline string of fixed config paths to append. One path for each line. Each path should be relative to the working directory.
type: string
generated-config-path:
default: /tmp/generated-config.yml
description: |
A file path for the generated config file.
type: string
steps:
- checkout
- when:
condition: << parameters.fixed-config-paths >>
steps:
- append-fixed-paths:
config-list-path: << parameters.config-list-path >>
fixed-config-paths: << parameters.fixed-config-paths >>
- when:
condition: << parameters.find-config-regex >>
steps:
- append-find-result:
config-list-path: << parameters.config-list-path >>
find-config-regex: << parameters.find-config-regex >>
- generate-config:
config-list-path: << parameters.config-list-path >>
generated-config-path: << parameters.generated-config-path >>
- when:
condition: << parameters.continuation >>
steps:
- continuation/continue:
circleci_domain: << parameters.continuation-circleci_domain >>
configuration_path: << parameters.generated-config-path >>
parameters: << parameters.continuation-parameters >>
examples:
config-list-path:
description: |
You can write the split config paths in a file and set it to the config-list-path parameter.
Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
usage:
version: "2.1"
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
config-list-path: .circleci/config-list
find-config-regex:
description: |
You can use regex to specify the split configs.
Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
usage:
version: "2.1"
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
find-config-regex: .*/\.circleci/config\.yml
fixed-config-paths:
description: |
You can use fixed-config-paths parameter to specify the split configs.
Please check README in the GitHub repository for more details: https://github.com/bufferings/orb-split-config
usage:
version: "2.1"
orbs:
split-config: bufferings/split-config@1.2.3
workflows:
generate-config:
jobs:
- split-config/generate-config:
fixed-config-paths: |
./common/.circleci/config.yml
./service1/.circleci/config.yml
./service2/.circleci/config.yml
./service3/.circleci/config.yml