Config workflow validation error - Build Env - expected type: Mapping, found: Sequence

Hi guys,

I have a problem with my configuration file but I don’t know what is wrong with my configuration.

I get the following error output:

2. [#/jobs/production] expected type: String, found: Mapping
 |   |   Job may be a string reference to another job

What am I doing wrong can someone help?

My config:

version: 2.1

executors:
  node:
    docker:
      - image: circleci/node:10.16

commands:
  flow:
    parameters:
      environment:
        type: string
        default: "production"
      yarn:
        type: string
        default: "yarn prod-build"
    steps:
      - add_ssh_keys:
          fingerprints:
            - xxx
      - store_test_results:
          path: test-results
      - checkout
      - restore_cache:
          name: Restore Yarn Package & Packge.json Cache
          keys:
            - yarn-packages-{{ checksum "yarn.lock" }}
            - v1-dependencies-{{ checksum "package.json" }}
            - yarn-packages-
            - v1-dependencies-
      - run:
          name: Install Yarn Packages
          command: yarn install
      - run:
          name: Building Repo
          command: << parameters.yarn >>
      - save_cache:
          name: Save Yarn Package Cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run:
          name: Run SSH keyscan
          command: ssh-keyscan ${hostname} >> ~/.ssh/known_hosts
      - run:
          name: Install Rysnc
          command: sudo apt-get install rsync
      - run:
          name: Upload files to theme folder
          command: rsync -avP --delete-before --exclude 'node_modules' --exclude '.git'
            --exclude 'webpack' --exclude '.circleci' --exclude 'src' --exclude '.babelrc'
            --exclude '.browserslistrc' --exclude '.eslintrc' --exclude '.gitignore'
            --exclude '.prettierrc' --exclude '.stylelintignore' --exclude '.stylelintrc'
            --exclude 'env.json' --exclude 'package.json' --exclude 'yarn.lock' --exclude
            'README.md' ~/<< parameters.environment >>-theme ${username}@${hostname}:/var/www/html/${site_name}/wp-content/themes/


jobs:
  production:
    executor: node
    working_directory: ~/production-theme
    steps:
      - flow:
          - environment: "production"
          - yarn: "yarn prod-build"


  development:
    working_directory: ~/develop-theme
    docker:
      - image: circleci/node:10.16
    steps:
      - flow:
          - environment: "develop"
          - yarn: "yarn test-build"

workflows:
  version: 2
  production_and_development:
    jobs:
      - development:
          filters:
            branches:
              only: develop
      - production:
          filters:
            branches:
              only: master

Thanks!

I would guess your “Upload files to theme folder” command needs at least one of these:

  • Line continuation markers (backslash) on every non-last line
  • Change command to the multi-line format:
command: |
    rsync -avP --delete ...

So it should be:

  command: | rsync -avP --delete-before --exclude 'node_modules' --exclude '.git'
    --exclude 'webpack' --exclude '.circleci' --exclude 'src' --exclude '.babelrc'
    --exclude '.browserslistrc' --exclude '.eslintrc' --exclude '.gitignore'
    --exclude '.prettierrc' --exclude '.stylelintignore' --exclude '.stylelintrc'
    --exclude 'env.json' --exclude 'package.json' --exclude 'yarn.lock' --exclude
    'README.md' ~/<< parameters.environment >>-theme ${username}@${hostname}:/var/www/html/${site_name}/wp-content/themes/

What do you mean with: " * Line continuation markers (backslash) at the end of every non-last line"?

Can you explain?

Tnx.

No, see my example again - there is a newline after the bar. I think it is important to the YAML parser.

If you have a command comprising of more than one line in Unix/Linux, every newline you put in has to have a backslash at the end, except the last one. It signifies to the parser than another line is to come.

I have added a new line:

     command:| 
        rsync -avP --delete-before --exclude 'node_modules' --exclude '.git'
        --exclude 'webpack' --exclude '.circleci' --exclude 'src' --exclude '.babelrc'
        --exclude '.browserslistrc' --exclude '.eslintrc' --exclude '.gitignore'
        --exclude '.prettierrc' --exclude '.stylelintignore' --exclude '.stylelintrc'
        --exclude 'env.json' --exclude 'package.json' --exclude 'yarn.lock' --exclude
        'README.md' ~/<< parameters.environment >>-theme ${username}@${hostname}:/var/www/html/${site_name}/wp-content/themes/

This is what i have now:

I get another error:
# Unable to parse YAML
# while scanning a simple key
# in ‘string’, line 54, column 11:
# command:|
# ^
# could not find expected ‘:’
# in ‘string’, line 62, column 1:
# jobs:

When i try to validate i get an error:

can not read a block mapping entry; a multiline key may not be an implicit key at line 56, column 131: … /${site_name}/wp-content/themes/ ^

Wondering if you’re pulling my leg :smirk_cat:

So, I gave two things to try, and explained both of them twice, and the second one has still not been applied. Worth a try, d’ya reckon? :grin: Backslashes (\)…

I am really not, i really don’t understand.

Backslash where exactly? Which line after to add the backslash?

Try this:

:blush:

Maybe something like…

line 1 \
line 2 \
line 3

I understand but i have a config file which is 88 lines long where should i add the backslashes on the command with exclude or where?

Just on the lines that make up the command (five in your case, since you do not want to put a line continuation on the last one, since there is not continuation on the last one, by definition).

  - run:
      name: Run SSH keyscan
      command: ssh-keyscan ${hostname} >> ~/.ssh/known_hosts \

I will be doing you a huge disservice if I make the fix for you, since the only way to learn is to apply what you read. Do also search for “line continuation bash Linux” in your favourite search engine, if you wish.

I mentioned the command you are getting stuck on. You put it in this thread! It has five lines plus one:

I am signing off for the evening. I wish you the best of luck :shamrock: