Skip to content

Commit fcbd6e5

Browse files
Merge pull request circleci#1384 from circleci/improve-migrating-doc
Update migrating-from-1-2.md
2 parents 91e3122 + 88cfdce commit fcbd6e5

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

jekyll/_cci2/migrating-from-1-2.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ categories: [migration]
77
order: 15
88
---
99

10-
CircleCI 2.0 introduces the requirement that you create a configuration file (`.circleci/config.yml`), and it adds new required keys for which values must be defined. This release also allows you to use multiple jobs in your configuration. **Note:** If you configure multiple jobs, it is important to have parallelism set to `1` to prevent duplication of job runs.
10+
This document will give you a starting place for migrating from CircleCI 1.0 to 2.0 by using a copy of your existing 1.0 configuration file and replacing the old keys with the new keys if equivalents exist. The migration process may not end with this document, but the goal is to get the majority of keys replaced with the equivalent syntax nesting and to help you get started with adding new functionality.
1111

12-
If you already have a `circle.yml` file, this article will help you make a copy your existing file, create the new required keys, and then search and replace your 1.0 keys with 2.0 keys. If you do not have a `circle.yml` file, refer to the [Sample 2.0 `config.yml` File]({{ site.baseurl }}/2.0/sample-config) to get started from scratch.
12+
If you do not have a `circle.yml` file, refer to the [Sample 2.0 `config.yml` File]({{ site.baseurl }}/2.0/sample-config) to get started from scratch.
1313

1414
* Contents
1515
{:toc}
1616

17+
## Overview
18+
19+
CircleCI 2.0 introduces the requirement that you create a configuration file (`.circleci/config.yml`), and it adds new required keys for which values must be defined. This release also allows you to use multiple jobs in your configuration. **Note:** If you configure multiple jobs, it is important to have parallelism set to `1` to prevent duplication of job runs.
20+
21+
If you already have a `circle.yml` file, the following sections describe how to make a copy your existing file, create the new required keys, and then search and replace your 1.0 keys with 2.0 keys.
22+
1723
## Steps to Configure Required 2.0 Keys
1824

1925
1. Copy your existing `circle.yml` file into a new directory called `.circleci` at the root of your project repository.
@@ -22,12 +28,12 @@ If you already have a `circle.yml` file, this article will help you make a copy
2228

2329
3. Add `version: 2` to the top of the `.circleci/config.yml` file.
2430

25-
4. Add the following two lines to your `config.yml` file, after the version line. If your configuration includes `machine:`, replace `machine:` with the following two lines, nesting all of the following sections under `build`.
31+
4. Add the following two lines to your `config.yml` file, after the version line. If your configuration includes `machine:`, replace `machine:` with the following two lines, nesting all of the sections of the old config file under `build`.
2632
```
2733
jobs:
2834
build:
2935
```
30-
5. Add the language and version to your configuration using either the `docker:` and `- image:` keys in the example or by setting `machine: true`. If your configuration includes language and version as shown for `ruby:` below, replace it as shown.
36+
5. Add the language and version you want to run the primary container to your configuration using either the `docker:` and `- image:` keys in the example or by setting `machine: true`. If your configuration includes language and version as shown for `ruby:` below, replace it as shown.
3137
```
3238
ruby:
3339
version: 2.3
@@ -37,7 +43,7 @@ If you already have a `circle.yml` file, this article will help you make a copy
3743
docker:
3844
- image: circleci/ruby:2.3
3945
```
40-
The primary container is an instance of the first list image listed. Your build commands run in this container and must be declared for each job.
46+
The primary container is an instance of the first list image listed. Your build commands run in this container and must be declared for each job.
4147
4248
6. The `checkout:` step is required to run jobs on your source files. Nest `checkout:` under `steps:` for every job by search and replacing
4349
```
@@ -50,6 +56,8 @@ If you already have a `circle.yml` file, this article will help you make a copy
5056
- checkout
5157
- run:
5258
```
59+
If you do not have a `checkout` step, you must add this step to your `config.yml` file.
60+
5361
7. Validate your YAML at <http://codebeautify.org/yaml-validator> to check the changes.
5462
5563
## Steps to Configure Workflows
@@ -93,7 +101,7 @@ Optionally configure workflows, using the following instructions:
93101
branches:
94102
ignore: master
95103
```
96-
6. Validate your YAML again at <http://codebeautify.org/yaml-validator> to check the changes.
104+
6. Validate your YAML again at <http://codebeautify.org/yaml-validator> to check that it is well-formed.
97105
98106
## Search and Replace Deprecated 2.0 Keys
99107
@@ -115,8 +123,8 @@ With the following to load it into your shell (the file $BASH_ENV already exists
115123
116124
```
117125
steps:
118-
run: echo 'export PATH=/path/to/foo/bin:$PATH' >> $BASH_ENV
119-
run: some_program_inside_bin
126+
- run: echo 'export PATH=/path/to/foo/bin:$PATH' >> $BASH_ENV
127+
- run: some_program_inside_bin
120128
```
121129
122130
- Search and replace the `hosts:` key, for example:
@@ -181,4 +189,10 @@ With the following, nested under `steps:` and customizing for your application a
181189
182190
## Validate YAML
183191
184-
When you have all the sections in `.circleci/config.yml` we recommend that you validate your YAML syntax using a tool such as <http://codebeautify.org/yaml-validator>. Fix up any issues and commit the updated `.circleci/config.yml` file. When you push a commit the job will start automatically and you can monitor it in the CircleCI app.
192+
When you have all the sections in `.circleci/config.yml` we recommend that you check that your YAML syntax is well-formed using a tool such as <http://codebeautify.org/yaml-validator>. Then, use the `circleci` CLI to validate that the new configuration is correct with regard to the CircleCI 2.0 schema. See the [Using the CircleCI Command Line Interface (CLI)]({{ site.baseurl }}/2.0/local-jobs/) document for instructions. Fix up any issues and commit the updated `.circleci/config.yml` file. When you push a commit the job will start automatically and you can monitor it in the CircleCI app.
193+
194+
## Next Steps
195+
196+
- Refer to the [Specifying Container Images]({{ site.baseurl }}/2.0/executor-types/) document for more information about Docker and Machine images in CircleCI 2.0.
197+
- Refer to the [Writing Jobs With Steps]({{ site.baseurl }}/2.0/configuration-reference/) document for details on the exact syntax of CircleCI 2.0 `jobs` and `steps` and all available options.
198+

0 commit comments

Comments
 (0)