4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【CircleCI】extraneous key [command] is not permittedが出てbuildできない

Posted at

circleciにてテストとデプロイを行っていたのですが、extraneous key [command] is not permittedというエラーに遭遇しました。

元のコード

..circleci/config.yml
version: 2.1
executors:
  default:
    docker:
      - image: circleci/ruby:2.5-node-browsers
      - image: circleci/mysql:5.6


    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
      - MYSQL_ROOT_HOST: '%'
      - RAILS_ENV: 'test'
      - BUNDLER_VERSION: 2.0.2

    working_directory: ~/repo

commands:
  setup_bundler_and_cache:
    steps:
      - checkout
      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "Gemfile.lock" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run:
          name: install dependencies
          command: |
            gem install bundler -v 2.0.2
            bundle install --jobs=4 --retry=3 --path vendor/bundle

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}
jobs:
  build:
    executor: default
    steps:
      - setup_bundler_and_cache

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load

      - add_ssh_keys:
          fingerprints:
            - "{$ SSH_KEY}"

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results

  Rubocop_correction:
    executor: default
    steps:
      - setup_bundler_and_cache
      - run:
       command: bundle exec rubocop -a
  RuboCop_test:
    executor: default
    steps:
      - setup_bundler_and_cache
      - run:
          command: bundle exec rubocop --fail-level w --display-only-fail-level-offenses

  Rspec_test:
    executor: default
    steps:
      - setup_bundler_and_cache
      - run:
          command: bundle exec rspec

  deploy:
    executor: default
    steps:
      - setup_bundler_and_cache
      #deploy with capistrano
      - run:
          name: Capistrano deploy
          command: |
            if [ "${CIRCLE_BRANCH}" != "master" ]; then
              exit 0
            fi
            bundle exec cap production deploy


workflows:
  version: 2.1
  build_test_and_deploy:
    jobs:
      - build
      - Rubocop_correction:
          requires:
            - build
      - RuboCop_test:
          requires:
            - build
      - Rspec_test:
          requires:
            - build
      - deploy:
          requires:
            - RuboCop_test
            - Rspec_test

以下エラー文


# !/bin/sh -eo pipefail
# ERROR IN CONFIG FILE:
# [#/jobs/Rubocop_correction] only 1 subschema matches out of 2
# 1. [#/jobs/Rubocop_correction/steps/4] 0 subschemas matched instead of one
# |   1. [#/jobs/Rubocop_correction/steps/4] extraneous key [command] is not permitted
# |   |   Permitted keys:
# |   |     - persist_to_workspace
# |   |     - save_cache
# |   |     - run
# |   |     - checkout
# |   |     - attach_workspace
# |   |     - store_test_results
# |   |     - restore_cache
# |   |     - store_artifacts
# |   |     - add_ssh_keys
# |   |     - deploy
# |   |     - setup_remote_docker
# |   |   Passed keys:
# |   |     []
# |   2. [#/jobs/Rubocop_correction/steps/4] Input not a valid enum value
# |   |   Steps without arguments can be called as strings
# |   |     enum:
# |   |     - checkout
# |   |     - setup_remote_docker
# |   |     - add_ssh_keys
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false

Exited with code exit status 1
CircleCI received exit code 1

原因はインデントミス

runコマンドを実行する際のインデントが1つ分足りておらず、コマンドとして認識されていなかったようです。

正しいフォーマットに訂正することでbuildが成功しました。

..circkeci/config.yml

Rubocop_correction:
    executor: default
    steps:
      - setup_bundler_and_cache
      - run:
        command: bundle exec rubocop -a #<-- インデントが一つ足りていなかった
                                             
 ------------------------------------------------------------------------------

Rubocop_correction:
    executor: default
    steps:
      - setup_bundler_and_cache
      - run:
          command: bundle exec rubocop -a #<-- 正しくはスペースキー2回分

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?