Config does not conform to schema:

Hi I am trying to deploy after the branch is merge but for reason i am getting this error: Config does not conform to schema: {:workflows {:build-and-deploy {:jobs [{:build (not (map? nil))} {:deploy {:requires [(not (instance? java.lang.String #ordered/map ([:build nil])))]}}]}}}
I have tried many indentation fixed and none of them work, the configuration was working fine from line 1 to line 59 which is the build and run some test. But i wanted to add the automated deployment and now i am stuck on this. can someone help please? Thank you.

# Ruby CircleCI 2.0 configuration file
#
version: 2
general:
  branches:
    only:
      - master
      - rapid-screen
      - lens-3
      - rs-staging

jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.3.7-node-browsers
      - image: circleci/mongo:3.0.15

    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-

      # Install mongotools
      - run:
          name: Install mongotools
          command: |
            wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo dpkg -i libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo apt-get install -y apt-transport-https apt-utils
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org-shell=3.0.15 mongodb-org-tools=3.0.15

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

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec

  deploy:
    machine:
      enabled: true
      steps:
        - checkout
        - run:
            name: Deploy to Testing
            command: |
            if [ "${CIRCLE_BRANCH}" == "sc-test" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_ucm && STAGE=staging-ucm cap deploy'; else echo "Skipped"; fi:
        - run:
            name: Deploy to Staging
            command: |
            if [ "${CIRCLE_BRANCH}" == "rs-staging" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_rapid_screen && STAGE=staging-rapid-screen cap deploy'; else echo "Skipped"; fi:

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build:
      - deploy:
          requires:
            - build:
          filters:
            branches:
              only:
                - sc-test
                - rs-staging

It’s a YAML problem - drop the colon in the two build elements. These are values, not keys.

Thank you very much Halfer, After removing those colon from build, i am getting this error now. Not really sure what part of the code is not being supported.

Build-agent version 0.1.1480-7a5183d3 (2019-01-22T18:14:45+0000)
Configuration errors: 1 error occurred:

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

* in job 'deploy': steps is not a list
* in job 'deploy': steps is not a list

Dunno. Paste the whole of your new YAML, maybe that will make it clear. Check you don’t have any tabs in there.

Ops ok, I have been using yamllint to check error in the file. Thank you very much for your help I appreciate it.

# Ruby CircleCI 2.0 configuration file
#
version: 2
general:
  branches:
    only:
      - master
      - rapid-screen
      - lens-3
      - rs-staging

jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.3.7-node-browsers
      - image: circleci/mongo:3.0.15

    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-

      # Install mongotools
      - run:
          name: Install mongotools
          command: |
            wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo dpkg -i libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo apt-get install -y apt-transport-https apt-utils
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org-shell=3.0.15 mongodb-org-tools=3.0.15

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

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec

  deploy:
    machine:
      enabled: true
      steps:
        - checkout
        - run:
            name: Deploy to Testing
            command: |
            if [ "${CIRCLE_BRANCH}" == "sc-test" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_ucm && STAGE=staging-ucm cap deploy'; else echo "Skipped"; fi:
        - run:
            name: Deploy to Staging
            command: |
            if [ "${CIRCLE_BRANCH}" == "rs-staging" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_rapid_screen && STAGE=staging-rapid-screen cap deploy'; else echo "Skipped"; fi:

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - sc-test
                - rs-staging

Use this parser to see the problem in your deploy job. The commands are not indented in the same way as the other job, and they are malformed as a result.

I also don’t recognise the general: device - remove that for now. It does not appear to be a job or a workflow.

Hi Halfer, I was not really sure about the command being malformed, can you help me with that.
I modified the file and it seem that now the error are in the commands. this is the error i am getting:

#!/bin/bash -eo pipefail if [ “${CIRCLE_BRANCH}” == “sc-test” ]; then ssh SSH_USER@SSH_HOST ‘cd /srv/staging_ucm && STAGE=staging-ucm cap deploy’; else echo “Skipped”; fi:

/bin/bash: -c: line 1: syntax error: unexpected end of file Exited with code 2

This is the current configuration and with this the build/test passed but when i do the merge it fail after the successful test.

# Ruby CircleCI 2.0 configuration file
#
version: 2
# general:
#   branches:
#    only:
#      - master
#      - rapid-screen
#      - lens-3
#      - rs-staging

jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.3.7-node-browsers
      - image: circleci/mongo:3.0.15

    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-

      # Install mongotools
      - run:
          name: Install mongotools
          command: |
            wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo dpkg -i libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo apt-get install -y apt-transport-https apt-utils
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org-shell=3.0.15 mongodb-org-tools=3.0.15

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

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec

  deploy:
    machine:
      enabled: true
    steps:
      - checkout
      - run:
          name: Deploy to Testing
          command: |
            if [ "${CIRCLE_BRANCH}" == "sc-test" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_ucm && STAGE=staging-ucm cap deploy'; else echo "Skipped"; fi:
      - run:
          name: Deploy to Staging
          command: |
            if [ "${CIRCLE_BRANCH}" == "rs-staging" ]; then ssh SSH_USER@SSH_HOST 'cd /srv/staging_rapid_screen && STAGE=staging-rapid-screen cap deploy'; else echo "Skipped"; fi:

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - sc-test
                - rs-staging

I expect the colon in fi should not be there.

I’d add that if you’re struggling with YAML, or CI, then try to get the smallest possible configuration working. Don’t try to fix ten problems at once. When you get an error, don’t come straight back to the help forum to ask about the new problem - you will not learn anything that way. Cut the problem down, debug it, and ask when you are properly stuck.

Going through the pain of debugging anything is one of the best ways you can learn. Good luck!

Ok thank you very much halfer, quick question, when trying to deploy through ssh I have to connect to the IP of the container that circle is using or the actual server that i have ?

Thanks,

You need to SSH into the server that you are deploying to. An example of this in action can be found here: https://github.com/launchdarkly/SupportService/blob/master/scripts/deploy.sh

This script is called as a part of the deploy job in the config of the repo.

Even with a reasonable experience level with CircleCI, I spend a long time getting the schema right. Sometimes I get a somewhat useful error from CircleCI that guides me to my error, but it’s a slow development iteration.

Feature request for CircleCI! How about an online tool where you can paste in your script and it will lint it, and describe in a more consumable way what the script does so that you can spot any errors?

Thank you very much for your help Levlaz, I was able to make it work using ssh but i think that is not the right way to trigger a deployment from the sever, so i decided to use the same container in order to execute the deployment command to the server. I am running into a problem because the capistrano command can not be found using absolute path or just executing bundle exec cap deploy noticed that i am executing bundle exec rspec to trigger the test, do you guys have any idea why this is happening or how i could run capistrano from the container image ?

# Ruby CircleCI 2.0 configuration file
#
version: 2
# general:
#   branches:
#    only:
#      - master
#      - rapid-screen
#      - lens-3
#      - rs-staging

jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/ruby:2.3.7-node-browsers
      - image: circleci/mongo:3.0.15

    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-

      # Install mongotools
      - run:
          name: Install mongotools
          command: |
            wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo dpkg -i libssl1.0.0_1.0.1f-1ubuntu2.27_amd64.deb
            sudo apt-get install -y apt-transport-https apt-utils
            sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
            echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
            sudo apt-get update
            sudo apt-get install -y mongodb-org-shell=3.0.15 mongodb-org-tools=3.0.15

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

      - save_cache:
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

            bundle exec rspec

  deploy:
    docker:
      - image: circleci/ruby:2.3.7-node-browsers
#    machine:
#      enabled: true
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: |
            gem install bundler -v 1.17.3
            gem install capistrano -v 2.9.0
            bundle install --jobs=4 --retry=3 --path vendor/bundle
      - run:
          name: Deploy to Testing
          command: |
                  if [ "${CIRCLE_BRANCH}" == "sc-test" ]; then './bin/bundle exec cap deploy'; else echo "Skipped"; fi
          environment:
            STAGE: staging-ucm

      - run:
          name: Deploy to Staging
          command: |
            if [ "${CIRCLE_BRANCH}" == "rs-staging" ]; then ssh $SSH_USER@$SSH_HOST 'cd /srv/staging_rapid_screen/current && STAGE=staging-rapid-screen cap deploy'; else echo "Skipped"; fi

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only:
                - sc-test
                - rs-staging

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