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
Copy file name to clipboardExpand all lines: jekyll/_cci2/configuration-reference.md
+44-47Lines changed: 44 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,23 @@ order: 0
8
8
9
9
This document is a reference for `.circleci/config.yml` which describes jobs and steps to build/test/deploy your project. The presence of this file indicates that you want to use the 2.0 infrastructure. This allows you to test 2.0 builds on a separate branch, leaving any existing configuration in the old `circle.yml` style unaffected and running on the CircleCI 1.0 infrastructure in branches that do not contain `.circleci/config.yml`.
10
10
11
-
The `config.yml`file has the following format:
11
+
You can see a complete `config.yml`in our [full example](#full-example).
12
12
13
-
## Root
13
+
---
14
+
15
+
## Table of Contents
16
+
{:.no_toc}
17
+
18
+
* TOC
19
+
{:toc}
20
+
21
+
---
22
+
23
+
## **`version`**
14
24
15
25
Key | Required | Type | Description
16
26
----|-----------|------|------------
17
27
version | Y | String | Should currently be `2`
18
-
jobs | Y | List | A list of jobs, see the definition for a job
19
28
{: class="table table-striped"}
20
29
21
30
The `version` field is intended to be used in order to issue warnings for deprecation or breaking changes.
@@ -28,8 +37,8 @@ Each job consists of the job's name as a key and a map as a value. A name should
28
37
29
38
Key | Required | Type | Description
30
39
----|-----------|------|------------
31
-
docker | Y <sup>(1)</sup> | List | Options for [docker executor](#docker-executor)
32
-
machine | Y <sup>(1)</sup> | Map | Options for [machine executor](#machine-executor)
40
+
docker | Y <sup>(1)</sup> | List | Options for [docker executor](#docker)
41
+
machine | Y <sup>(1)</sup> | Map | Options for [machine executor](#machine)
33
42
steps | Y | List | A list of [steps](#steps) to be performed
34
43
working_directory | Y | String | What directory to run the steps in. (previously called `workDir`).
35
44
parallelism | N | Integer | Number of parallel instances of this job to run (default: 1)
@@ -62,11 +71,13 @@ jobs:
62
71
- run: make
63
72
```
64
73
65
-
## Executors
74
+
### **`docker`** | **`machine`** (_executor_)
66
75
67
76
An "executor" is roughly "a place where steps occur". CircleCI 2.0 can build the necessary environment by launching as many docker containers as needed at once. Learn more about [different executors]({{ site.baseurl }}/2.0/executor-types/).
68
77
69
-
### Docker executor
78
+
#### `docker`
79
+
{:.no_toc}
80
+
70
81
Configured by `docker` key which takes a list of maps:
Configured by using the `machine` key, which takes a map:
113
126
114
127
Key | Required | Type | Description
@@ -133,11 +146,9 @@ jobs:
133
146
machine: true
134
147
```
135
148
136
-
## **`branches`**
137
-
138
-
Defines rules for whitelisting/blacklisting execution of some branches.
149
+
### **`branches`**
139
150
140
-
### Configuration map
151
+
Defines rules for whitelisting/blacklisting execution of some branches. Takes a map:
141
152
142
153
Key | Required | Type | Description
143
154
----|-----------|------|------------
@@ -169,7 +180,7 @@ If both `ignore` and `only` are present in config, only `ignore` will be taken i
169
180
170
181
A job that was not executed due to configured rules will show up in the list of jobs in UI, but will be marked as skipped.
171
182
172
-
## **`steps`**
183
+
### **`steps`**
173
184
174
185
The `steps` setting in a job should be a list of single key/value pairs, the key of which indicates the step type. The value may be either a configuration map or a string (depending on what that type of step requires). For example, using a map:
<step_type> | Y | Map or String | A configuration map for the step or some string whose semantics are defined by the step.
217
228
{: class="table table-striped"}
218
229
219
-
Configuration map is specific for each step and described [below](#built-in-steps).
220
-
221
-
### Built-in steps
222
-
223
-
In the future you will be able to refer to external and custom step types, but for now you are limited to these built-in predefined steps.
230
+
Each built-in step is described in detail below.
224
231
225
232
#### **`run`**
226
233
227
234
Used for invoking all command-line programs, taking either a map of configuration values, or, when called in its short-form, a string that will be used as both the `command` and `name`. Run commands are executed using non-login shells by default, so you must explicitly source any dotfiles as part of the command.
228
235
229
-
##### **Configuration map**
230
-
231
236
Key | Required | Type | Description
232
237
----|-----------|------|------------
233
238
command | Y | String | Command to run via the shell
@@ -249,11 +254,11 @@ Each `run` declaration represents a new shell. It's possible to specify a multi-
249
254
make test
250
255
```
251
256
252
-
##### **Default shell options**
257
+
##### _Default shell options_
253
258
254
259
Our default `shell` has a few options enabled by default:
255
260
256
-
**`-e` option**
261
+
`-e`
257
262
258
263
> Exit immediately if a pipeline (which may consist of a single simple command), a subshell command enclosed in parentheses, or one of the commands executed as part of a command list enclosed by braces exits with a non-zero status.
259
264
@@ -274,7 +279,7 @@ So if in the previous example `mkdir` failed to create a directory and returned
274
279
make test
275
280
```
276
281
277
-
**`-o pipefail` option**
282
+
`-o`
278
283
279
284
> If pipefail is enabled, the pipeline’s return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit successfully. The shell waits for all commands in the pipeline to terminate before returning a value.
280
285
@@ -291,7 +296,8 @@ If you want to avoid this behaviour, you can specify `set +o pipefail` in the co
291
296
292
297
In general, we recommend using the default options (`-eo pipefail`) because they show errors in intermediate commands and simplify debugging job failures. For convenience, the UI displays the used shell and all active options for each `run` step.
293
298
294
-
##### **Background command**
299
+
##### _Background commands_
300
+
295
301
The `background` attribute allows for executing commands in the background. In this case, job execution will immediately proceed to the next step rather than waiting for the command to return. While debugging background commands is more difficult, running commands in the background might be necessary in some cases. For instance, to run Selenium tests you may need to have X virtual framebuffer running:
296
302
297
303
``` YAML
@@ -303,7 +309,8 @@ The `background` attribute allows for executing commands in the background. In t
303
309
- run: make test
304
310
```
305
311
306
-
##### **Shorthand syntax**
312
+
##### _Shorthand syntax_
313
+
307
314
`run` has a very convenient shorthand syntax:
308
315
309
316
``` YAML
@@ -316,7 +323,8 @@ The `background` attribute allows for executing commands in the background. In t
316
323
```
317
324
In this case, `command` and `name` become the string value of `run`, and the rest of the config map for that `run` have their default values.
318
325
319
-
##### **Complete example of `run` **
326
+
##### _Example_
327
+
320
328
``` YAML
321
329
- run:
322
330
name: Testing application
@@ -339,8 +347,6 @@ In this case, `command` and `name` become the string value of `run`, and the res
339
347
340
348
Special step used to check out source code to the configured `path` (defaults to the `working_directory`).
@@ -356,13 +362,10 @@ In the case of `checkout`, the step type is just a string with no additional att
356
362
- checkout
357
363
```
358
364
359
-
360
365
<a name="save_cache"/>
361
366
#### **`save_cache`**
362
367
363
-
Generates and stores a cache of a file or directory of files such as dependencies or source code in our object storage. Later builds can restore this cache (using a [`restore_cache` step](#restore_cache)). Learn more in [the caching documentation]({{ site.baseurl }}/2.0/caching/).
364
-
365
-
**Configuration map**
368
+
Generates and stores a cache of a file or directory of files such as dependencies or source code in our object storage. Later builds can [restore this cache](#restore_cache). Learn more in [the caching documentation]({{ site.baseurl }}/2.0/caching/).
366
369
367
370
Key | Required | Type | Description
368
371
----|-----------|------|------------
@@ -372,7 +375,7 @@ key | Y | String | Unique identifier for this cache
372
375
373
376
The cache for a specific `key` is immutable and cannot be changed once written. NOTE: _If the cache for the given `key` already exists it won't be modified, and job execution will proceed to the next step._
374
377
375
-
When storing a new cache, `key` value may contains special templated values for your convenience:
378
+
When storing a new cache, the `key` value may contain special templated values for your convenience:
376
379
377
380
Template | Description
378
381
----|----------
@@ -398,7 +401,7 @@ While choosing suitable templates for your cache `key`, keep in mind that cache
398
401
<b>Tip:</b> Given the immutability of caches, it might be helpful to start all your cache keys with a version prefix <code class="highlighter-rouge">v1-...</code>. That way you will be able to regenerate all your caches just by incrementing the version in this prefix.
399
402
</div>
400
403
401
-
##### **Complete example**
404
+
##### _Example_
402
405
403
406
{% raw %}
404
407
``` YAML
@@ -414,8 +417,6 @@ While choosing suitable templates for your cache `key`, keep in mind that cache
414
417
415
418
Restores a previously saved cache based on a `key`. Cache needs to have been saved first for this key using [`save_cache` step](#save_cache). Learn more in [the caching documentation]({{ site.baseurl }}/2.0/caching/).
416
419
417
-
##### **Configuration map**
418
-
419
420
Key | Required | Type | Description
420
421
----|-----------|------|------------
421
422
key | Y <sup>(1)</sup> | String | Single cache key to restore
@@ -456,7 +457,8 @@ When CircleCI encounters a list of `keys`, the cache will be restored from the f
456
457
457
458
A path is not required here because the cache will be restored to the location from which it was originally saved.
458
459
459
-
##### **Complete example**
460
+
##### _Example_
461
+
460
462
{% raw %}
461
463
``` YAML
462
464
- restore_cache:
@@ -483,7 +485,7 @@ Special step for deploying artifacts.
483
485
484
486
In general `deploy` step behaves just like `run` with one exception - in a build with `parallelism`, the `deploy` step will only be executed by node #0 and only if all nodes succeed. Nodes other than #0 will skip this step.
485
487
486
-
##### **Example**
488
+
##### _Example_
487
489
488
490
``` YAML
489
491
- deploy:
@@ -498,8 +500,6 @@ In general `deploy` step behaves just like `run` with one exception - in a build
498
500
<!-- TODO: replace the 1.0 link here with a 2.0 link -->
499
501
Step to store artifacts (for example logs, binaries, etc) to be available in the web UI or via the API. Learn more about [artifacts]({{ site.baseurl }}/1.0/build-artifacts/)
500
502
501
-
##### **Configuration map**
502
-
503
503
Key | Required | Type | Description
504
504
----|-----------|------|------------
505
505
path | Y | String | Directory in the primary container to save as build artifacts
@@ -508,7 +508,7 @@ destination | Y | Prefix added to the artifact paths in the artifacts API
508
508
509
509
There can be multiple `store_artifacts` steps in a job. Using a unique prefix for each step prevents them from overwriting files.
510
510
511
-
##### **Example**
511
+
##### _Example_
512
512
513
513
``` YAML
514
514
- store_artifacts:
@@ -520,16 +520,14 @@ There can be multiple `store_artifacts` steps in a job. Using a unique prefix fo
520
520
521
521
Special step used to upload test results to be stored in artifacts and shown in the web UI.
522
522
523
-
##### **Configuration map**
524
-
525
523
Key | Required | Type | Description
526
524
----|-----------|------|------------
527
525
path | Y | String | Directory containing JUnit XML or Cucumber JSON test metadata files
528
526
{: class="table table-striped"}
529
527
530
528
The directory layout should match the [classic CircleCI test metadata directory layout]({{ site.baseurl }}/1.0/test-metadata/#metadata-collection-in-custom-test-steps).
531
529
532
-
##### **Example**
530
+
##### _Example_
533
531
534
532
``` YAML
535
533
- store_test_results:
@@ -540,8 +538,6 @@ The directory layout should match the [classic CircleCI test metadata directory
540
538
541
539
Special step that adds SSH keys configured in the project's UI to the container.
542
540
543
-
##### **Configuration map**
544
-
545
541
Key | Required | Type | Description
546
542
----|-----------|------|------------
547
543
fingerprints | N | List | List of fingerprints corresponding to the keys to be added (default: all keys added)
@@ -577,7 +573,8 @@ Then `source` the ssh configuration in `run` steps that require an ssh-agent:
0 commit comments