Skip to content

Commit 22724a2

Browse files
authored
Clean up config ref structure (circleci#915)
* add TOC * add TOC and restructure headings * fix links
1 parent 71462be commit 22724a2

File tree

1 file changed

+44
-47
lines changed

1 file changed

+44
-47
lines changed

jekyll/_cci2/configuration-reference.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ order: 0
88

99
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`.
1010

11-
The `config.yml` file has the following format:
11+
You can see a complete `config.yml` in our [full example](#full-example).
1212

13-
## Root
13+
---
14+
15+
## Table of Contents
16+
{:.no_toc}
17+
18+
* TOC
19+
{:toc}
20+
21+
---
22+
23+
## **`version`**
1424

1525
Key | Required | Type | Description
1626
----|-----------|------|------------
1727
version | Y | String | Should currently be `2`
18-
jobs | Y | List | A list of jobs, see the definition for a job
1928
{: class="table table-striped"}
2029

2130
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
2837

2938
Key | Required | Type | Description
3039
----|-----------|------|------------
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)
3342
steps | Y | List | A list of [steps](#steps) to be performed
3443
working_directory | Y | String | What directory to run the steps in. (previously called `workDir`).
3544
parallelism | N | Integer | Number of parallel instances of this job to run (default: 1)
@@ -62,11 +71,13 @@ jobs:
6271
- run: make
6372
```
6473
65-
## Executors
74+
### **`docker`** | **`machine`** (_executor_)
6675

6776
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/).
6877

69-
### Docker executor
78+
#### `docker`
79+
{:.no_toc}
80+
7081
Configured by `docker` key which takes a list of maps:
7182

7283
Key | Required | Type | Description
@@ -108,7 +119,9 @@ jobs:
108119
- image: redis@sha256:54057dd7e125ca41afe526a877e8bd35ec2cdd33b9217e022ed37bdcf7d09673
109120
```
110121

111-
### Machine executor
122+
#### **`machine`**
123+
{:.no_toc}
124+
112125
Configured by using the `machine` key, which takes a map:
113126

114127
Key | Required | Type | Description
@@ -133,11 +146,9 @@ jobs:
133146
machine: true
134147
```
135148

136-
## **`branches`**
137-
138-
Defines rules for whitelisting/blacklisting execution of some branches.
149+
### **`branches`**
139150

140-
### Configuration map
151+
Defines rules for whitelisting/blacklisting execution of some branches. Takes a map:
141152

142153
Key | Required | Type | Description
143154
----|-----------|------|------------
@@ -169,7 +180,7 @@ If both `ignore` and `only` are present in config, only `ignore` will be taken i
169180

170181
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.
171182

172-
## **`steps`**
183+
### **`steps`**
173184

174185
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:
175186

@@ -216,18 +227,12 @@ Key | Required | Type | Description
216227
&lt;step_type> | Y | Map or String | A configuration map for the step or some string whose semantics are defined by the step.
217228
{: class="table table-striped"}
218229

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.
224231

225232
#### **`run`**
226233

227234
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.
228235

229-
##### **Configuration map**
230-
231236
Key | Required | Type | Description
232237
----|-----------|------|------------
233238
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-
249254
make test
250255
```
251256

252-
##### **Default shell options**
257+
##### _Default shell options_
253258

254259
Our default `shell` has a few options enabled by default:
255260

256-
**`-e` option**
261+
`-e`
257262

258263
> 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.
259264

@@ -274,7 +279,7 @@ So if in the previous example `mkdir` failed to create a directory and returned
274279
make test
275280
```
276281

277-
**`-o pipefail` option**
282+
`-o`
278283

279284
> 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.
280285

@@ -291,7 +296,8 @@ If you want to avoid this behaviour, you can specify `set +o pipefail` in the co
291296

292297
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.
293298

294-
##### **Background command**
299+
##### _Background commands_
300+
295301
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:
296302

297303
``` YAML
@@ -303,7 +309,8 @@ The `background` attribute allows for executing commands in the background. In t
303309
- run: make test
304310
```
305311

306-
##### **Shorthand syntax**
312+
##### _Shorthand syntax_
313+
307314
`run` has a very convenient shorthand syntax:
308315

309316
``` YAML
@@ -316,7 +323,8 @@ The `background` attribute allows for executing commands in the background. In t
316323
```
317324
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.
318325

319-
##### **Complete example of `run` **
326+
##### _Example_
327+
320328
``` YAML
321329
- run:
322330
name: Testing application
@@ -339,8 +347,6 @@ In this case, `command` and `name` become the string value of `run`, and the res
339347

340348
Special step used to check out source code to the configured `path` (defaults to the `working_directory`).
341349

342-
##### **Configuration map**
343-
344350
Key | Required | Type | Description
345351
----|-----------|------|------------
346352
path | N | String | Checkout directory (default: job's [`working_directory`](#jobs))
@@ -356,13 +362,10 @@ In the case of `checkout`, the step type is just a string with no additional att
356362
- checkout
357363
```
358364

359-
360365
<a name="save_cache"/>
361366
#### **`save_cache`**
362367

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/).
366369

367370
Key | Required | Type | Description
368371
----|-----------|------|------------
@@ -372,7 +375,7 @@ key | Y | String | Unique identifier for this cache
372375

373376
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._
374377

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:
376379

377380
Template | Description
378381
----|----------
@@ -398,7 +401,7 @@ While choosing suitable templates for your cache `key`, keep in mind that cache
398401
<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.
399402
</div>
400403

401-
##### **Complete example**
404+
##### _Example_
402405

403406
{% raw %}
404407
``` YAML
@@ -414,8 +417,6 @@ While choosing suitable templates for your cache `key`, keep in mind that cache
414417

415418
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/).
416419

417-
##### **Configuration map**
418-
419420
Key | Required | Type | Description
420421
----|-----------|------|------------
421422
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
456457

457458
A path is not required here because the cache will be restored to the location from which it was originally saved.
458459

459-
##### **Complete example**
460+
##### _Example_
461+
460462
{% raw %}
461463
``` YAML
462464
- restore_cache:
@@ -483,7 +485,7 @@ Special step for deploying artifacts.
483485

484486
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.
485487

486-
##### **Example**
488+
##### _Example_
487489

488490
``` YAML
489491
- deploy:
@@ -498,8 +500,6 @@ In general `deploy` step behaves just like `run` with one exception - in a build
498500
<!-- TODO: replace the 1.0 link here with a 2.0 link -->
499501
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/)
500502

501-
##### **Configuration map**
502-
503503
Key | Required | Type | Description
504504
----|-----------|------|------------
505505
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
508508

509509
There can be multiple `store_artifacts` steps in a job. Using a unique prefix for each step prevents them from overwriting files.
510510

511-
##### **Example**
511+
##### _Example_
512512

513513
``` YAML
514514
- store_artifacts:
@@ -520,16 +520,14 @@ There can be multiple `store_artifacts` steps in a job. Using a unique prefix fo
520520

521521
Special step used to upload test results to be stored in artifacts and shown in the web UI.
522522

523-
##### **Configuration map**
524-
525523
Key | Required | Type | Description
526524
----|-----------|------|------------
527525
path | Y | String | Directory containing JUnit XML or Cucumber JSON test metadata files
528526
{: class="table table-striped"}
529527

530528
The directory layout should match the [classic CircleCI test metadata directory layout]({{ site.baseurl }}/1.0/test-metadata/#metadata-collection-in-custom-test-steps).
531529

532-
##### **Example**
530+
##### _Example_
533531

534532
``` YAML
535533
- store_test_results:
@@ -540,8 +538,6 @@ The directory layout should match the [classic CircleCI test metadata directory
540538

541539
Special step that adds SSH keys configured in the project's UI to the container.
542540

543-
##### **Configuration map**
544-
545541
Key | Required | Type | Description
546542
----|-----------|------|------------
547543
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:
577573
my-command-that-uses-ssh
578574
```
579575

580-
### Putting it all together
576+
## _Full Example_
577+
{:.no_toc}
581578

582579
{% raw %}
583580
``` YAML

0 commit comments

Comments
 (0)