Error for yaml file

Im getting this errror:

  • Error parsing config file: yaml: line 1: mapping values are not allowed in this context
  • Cannot find a job named build to run in the jobs: section of your configuration file.
    If you expected a workflow to run, check your config contains a top-level key called ‘workflows:’

My yaml file:

  references:
  working_directory: &working_directory ~/code
  images: base_image: &base_image
  environment:
    BUNDLE_JOBS: 4
    BUNDLE_RETRY: 3
    BUNDLE_PATH: vendor/bundle
    RAILS_ENV: test
    CC_TEST_REPORTER_ID: eab6dc27076d631b996f74bd7c58709ff5c707926a20e1b23a8433c5b8462bac
    RAILS_DATABASE_HOST: localhost
db_image: &db_image
  image: circleci/postgres:9.6-alpine
  environment:
    POSTGRES_DB: myapp_test
    POSTGRES_USER: postgres
    POSTGRES_PASSWORD: ""
version: 2
jobs:
  build:
working_directory: *working_directory
docker:
  - *base_image
  - image: circleci/php:7.1.9-browsers
  
steps:
  - checkout
  - run:
      name: Setup dependencies
      command: |
        sudo composer self-update
        composer install -n --prefer-dist
  - run:
      name: Setup Code Climate test-reporter
      command: |
        curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
        chmod +x ./cc-test-reporter
  - run:
      name: Run tests
      command: |
        sudo docker-php-ext-enable xdebug
        ./cc-test-reporter before-build
        sudo vendor/bin/phpunit --coverage-clover clover.xml
        ./cc-test-reporter after-build --coverage-input-type clover --exit-code $?
  - restore_cache:
      name: Restore bundle cache
      keys:
        - rails-bundle-v1-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
        - rails-bundle-v1-{{ checksum ".ruby-version" }}-
  - run:
      name: Bundle Install
      command: bundle check || bundle install --clean
  - save_cache:
      name: Store bundle cache
      key: rails-bundle-v1-{{ checksum ".ruby-version" }}-{{ checksum "Gemfile.lock" }}
      paths:
        - vendor/bundle

  - restore_cache:
      name: Restore yarn cache
      keys:
        - rails-yarn-v1-{{ checksum "yarn.lock" }}
        - rails-yarn-v1-
  - run:
      name: Yarn Install
      command: yarn check || yarn install
  - save_cache:
      name: Store yarn cache
      key: rails-yarn-v1-{{ checksum "yarn.lock" }}
      paths:
        - node_modules

  - persist_to_workspace:
      root: *working_directory
      paths:
        - ./*

  test:
working_directory: *working_directory
docker:
  - *base_image
  - *db_image
steps:
  - attach_workspace:
      at: *working_directory

  - run:
      name: Wait for DB
      command: dockerize -wait tcp://localhost:5432 -timeout 1m

  - run:
      name: Database setup
      command: bin/rails db:schema:load --trace

  - type: shell
    command: |
      bundle exec rspec --profile 10 \
                        --format RspecJunitFormatter \
                        --out test_results/rspec.xml \
                        --format progress \
                        $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
  - store_test_results:
      path: test_results

  lint:
working_directory: *working_directory
docker:
  - *base_image
steps:
  - attach_workspace:
      at: *working_directory

  - run:
      name: bundle exec brakeman --exit-on-warn
      command: bundle exec brakeman --exit-on-warn

  - run:
      name: bundle exec danger
      command: bundle exec danger
      environment:
          LINT_OUTPUT: "lint_output"

  - store_artifacts:
      path: lint_output
      destination: lint_output

workflows:
  version: 2
  build_and_deploy:
jobs:
  - build
  - test:
      requires:
        - build
  - lint:
      requires:
        - build

fixed it! sorry didn’t mean to do that

There’s two YAML errors that I can see. The first is that this should not be indented at all

   references:

With this one it is difficult to know what was meant:

  images: base_image: &base_image

Put the whole thing in a dynamic YAML parser to check its validity.

It was not indented on my yaml file, but regardless getting the same error

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.