Migrating a Linux Project from 1.0 to 2.0

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.


如果你没有圆.ymlfile, refer to the示例2.0config.yml文件从头开始。


CircleCI要求您创建circleci先生/配置yml,and it adds new required keys for which values must be defined.Note:并行度只能在circleci先生/配置yml文件,则忽略CircleCI应用程序中的并行度设置。

If you already have a圆.ymlfile, the following sections describe how to make a copy of your existing file, create the new required keys, and then search and replace your 1.0 keys with 2.0 keys.


这个config-translationendpoint可以帮助您快速开始将1.0配置转换为2.0。有关详细信息,请参阅使用1.0到2.0config-translation Endpoint.

Steps to Configure Required Keys

  1. 复制现有的圆.yml一个名为circleci先生在root of your project repository.

  2. Renamecircleci先生/圆.ymltocircleci先生/配置yml.

  3. 添加version: 2到山顶circleci先生/配置ymlfile.

  4. 添加the following two lines to yourconfig.ymlfile, after the version line. If your configuration includes机器:,replace机器:with the following two lines, nesting all of the sections of the old config file underbuild.
  5. 使用docker:and-图片:示例中的键或通过设置机器:正确or by using马科斯.If your configuration includes language and version as shown forruby:如下图所示更换。

    Replace with the following lines:

    docker: - image: circleci/ruby:2.3-jessie auth: username: mydockerhub-user password: $DOCKERHUB_PASSWORD # context / project UI env-var reference

    这个primary container is an instance of the first image listed. Your job’s commands run in this container and must be declared for each job. See theDocker Getting Startedif you are new to Docker containers.


    请参阅的“使用机器”部分Choosing an Executor Typedocument for details about the available VM images.

  6. 这个结帐:step is required to run jobs on your source files. Nest结帐:在下面步骤:for every job by search and replacing

    智慧h the following:

    步骤:-checkout - run:

    For example:

    结帐:post: - mkdir -p /tmp/test-data - echo "foo" > /tmp/test-data/foo


    步骤:-签出-运行:mkdir-p/tmp/test data-运行:echo“foo”>/tmp/test data/foo

    如果你没有checkoutstep, you must add this step to yourconfig.ymlfile.

  7. (Optional) Add the添加\u ssh \u密钥step with fingeprint to enable SSH into builds, see the配置CircleCIdocument for details.

  8. 验证your YAML athttp://codebeatify.org/yaml-validatorto check the changes.



For more information, refer to the CircleCI 2.0 document使用环境变量.

Steps to Configure Workflows


  1. To use the Workflows feature, split your build job into multiple jobs, each with a unique name. It might make sense to start by just splitting out a deploy job to prevent you from having to re-run the entire build when only the deployment fails.

  2. As a best practice, add lines for工作流:,version: 2and结束of the mastercircleci先生/配置ymlfile, replacingwith a unique name for your workflow.Note:的“工作流”部分config.ymlfile is not nested in the config. It is best to put the Workflows at the end of the file because the Workflowsversion: 2除了version:key at the top of theconfig.ymlfile.
  3. 添加a line for the工作:key underand add a list of all of the job names you want to orchestrate. In this example,buildand测试将同时运行。

    工作流:版本:2:工作:-build - test
  4. For jobs which must run sequentially depending on success of another job, add therequires:键,其中包含必须成功才能启动的嵌套作业列表。如果你用的是curlcommand to start a job, Workflows enable you to remove the command and start the job by using therequires:钥匙。

    -: requires: - 
  5. 对于必须在特定分支上运行的作业,添加filters:key with a nestedbranchesandonly钥匙。对于不能在特定分支上运行的作业,请添加filters:key with a nestedbranchesand忽视钥匙。Note:工作流will ignore job-level branching, so if you have configured job-level branching and then add workflows, you must remove the branching at the job level and instead declare it in the workflows section of yourconfig.yml,如下所示:

  6. 再次验证您的YAMLhttp://codebeatify.org/yaml-validator检查它是否成形良好。

Search and Replace Deprecated 2.0 Keys

  • 如果您的配置设置了时区,请搜索并替换timezone: America/Los_Angeleswith the following two lines:
  • 如果您的配置修改了$PATH,请将该路径添加到.bashrcfile and replace

智慧h the following to load it into your shell (the file $BASH_ENV already exists and has a random name in /tmp):

步骤:-run:echo'export PATH=/PATH/to/foo/bin:$PATH'>>$BASH_ENV-run:some_program_inside_bin
  • Search and replace thehosts:键,例如:

智慧h an appropriaterun步骤,例如:

步骤:-run:echo circlehost | sudo tee-a/etc/hosts
  • Search and replace thedependencies:,database,or测试and覆盖:行,例如:

Is replaced with:

  • Search and replace the缓存目录:密钥:

智慧h the following, nested under步骤:并根据需要为您的应用程序定制:

  • 添加arestore_cache:key nested under步骤:.

  • Search and replace部署:在下面嵌套步骤:



当你有了所有的部分circleci先生/配置ymlwe recommend that you check that your YAML syntax is well-formed using a tool such ashttp://codebeatify.org/yaml-validator. 然后,使用circleciCLI来验证新配置是否与CircleCI 2.0架构相关。看到了吗使用CircleCI命令行界面(CLI)document for instructions. Fix up any issues and commit the updatedcircleci先生/配置ymlfile. When you push a commit the job will start automatically and you can monitor it in the CircleCI app.