【问题标题】:CircleCI migration: Config fileCircleCI 迁移:配置文件
【发布时间】:2018-08-10 08:52:16
【问题描述】:

我需要从 CirclceCI 1.0 迁移到 2.0 我正在尝试按照他们文档中提到的步骤进行操作。但无法获得正确的配置文件。 我的 1.0 版文件如下所示:

    ## Customize the test machine
    machine:

      timezone:
        America/New_York # List of timezones http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

      # Version of ruby to use
      ruby:
        version:
          2.3.1

    ## Customize database setup
    database:
      override:
        # replace Circle's generated database.yml
        - cp config/database.yml.ci config/database.yml
        - bundle exec rake db:create db:schema:load --trace

    test:
      minitest_globs:
        - test/**/*_test.rb

    steps:
      - checkout
        - post:
          - mkdir -p tmp

要迁移到版本 2,所做的修改是:

    version: 2
    ## Customize the test machine
    jobs:
      build:
        timezone:
          America/New_York # List of timezones http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

        # Version of ruby to use
        docker:
          - image: circleci/ruby:2.3-jessie

      ## Customize database setup
      database:
        - override:
          # replace Circle's generated database.yml
          - cp config/database.yml.ci config/database.yml
          - bundle exec rake db:create db:schema:load --trace

      test:
        - minitest_globs:
          - test/**/*_test.rb

      steps:
        - checkout:
        - run: mkdir -p tmp

在执行 CLI 命令进行验证时,如下所示: circleci 配置验证 -c .circleci/config.yml 我得到错误: 错误:发生 3 个错误:

     * Error migrating config to version 2: 2 errors occurred:

     * in job 'build': steps is not a list
     * in job 'build': steps is not a list
     * Config file is invalid:
      at jobs: steps: steps is required
      at jobs: timezone: Additional property timezone is not allowed
      at jobs: jobs: Invalid type. Expected: object, given: array
      at jobs: jobs: Invalid type. Expected: object, given: array
      at jobs: jobs: Invalid type. Expected: object, given: array

     * Error in config file: The schema/shape of the YAML is incorrect: json: cannot unmarshal array into Go value of type config.JobDescription

请求您帮助我了解我的问题所在以及需要进行的修改。

谢谢, M

【问题讨论】:

  • 您的问题最终解决了吗?我遇到了同样的错误,我的 yaml 文件事先通过codebeautify.org/yaml-validator 进行了验证。所以circle ci不喜欢就有点奇怪了。
  • 不,我终于不得不删除 CircleCI(暂时由于时间限制)。

标签: circleci-2.0


【解决方案1】:

CircleCI 2.0 弃用了您正在使用的某些选项,并需要其他选项。

  1. timezone is set as an environment variable
  2. Databases are declared as additional docker images
  3. 所有活动都以steps 的形式出现在job

f

version: 2
jobs:
  build:
    # Version of ruby to use
    docker:
      - image: circleci/ruby:2.3-jessie      
        environment:
          TZ: "/usr/share/zoneinfo/America/Los_Angeles"
      - image: circleci/postgres:9.6.2-alpine            
        environment:
          TZ: "/usr/share/zoneinfo/America/Los_Angeles"       
          POSTGRES_USER: root
          POSTGRES_DB: circle-test_test
    steps:  # run inside primary (ruby) container, with access to secondary (DB) container as localhost:db-port
      - checkout
      - run:
          name: Database Migration/Setup
          command: bundle exec rake db:create db:schema:load --trace
      - run:
          name: Execute Tests
          command: rspec test/**/*_test.rb  # change to appropriate testing commands

【讨论】:

    猜你喜欢
    • 2016-03-22
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 2012-04-29
    • 1970-01-01
    相关资源
    最近更新 更多