2

Good morning. I'm migrating from Gitlab to CircleCI and try to map out a simple pipeline ("workflow") that basically should look like this:

[build] -> [tests] -> [release*]
* only on tags

I wasted endless hours literally copy-pasting example configs from the documentation. I defined three jobs:

  1. build
  2. tests
  3. release

And I created a minimal workflow that just echos the job title, includes some requires (to map the pipeline) and have a condition that only triggers releases on tags.

However, I always get a YAML parsing error:

#!/bin/sh -eo pipefail
# Unable to parse YAML
# mapping values are not allowed here
#  in 'string', line 25, column 19:
#               requires:
#                       ^
# 
# -------
# 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 1

This is my config.yaml that currently fails:

version: 2
jobs:
  build:
    steps:
      - run:
          name: Compile Binaries
          command: echo "Compile Binaries"
  tests:
    steps:
      - run:
          name: Run All Tests
          command: echo "Run All Tests"
  build:
    steps:
      - run:
          name: Release Artifacts
          command: echo "Release Artifacts"

workflows:
  version: 2
  minimal:
    jobs:
      - build
      - tests
          requires:
            - build
      - release
          requires:
            - tests
          filters:
            tags:
              only: /^v.*$/

I also tried online YAML validators but they always say this is valid YAML, so something is wrong with the way Circle expects the config to be. What could it be?


Edit: I managed to even minify the example that causes the exact same error:

jobs:
  build:
    steps:
      - run:
          name: Release Artifacts
          command: echo "Release Artifacts"

workflows:
  minimal:
    jobs:
      - release
          filters:
            tags:
              only: /^v.*$/

Causes:

#!/bin/sh -eo pipefail
# Unable to parse YAML
# mapping values are not allowed here
#  in 'string', line 12, column 18:
#               filters:
#                      ^
# 
# -------
# 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 1

2 Answers 2

4

Running your config.yml through yamllint, produced the following:

  1:1       warning  missing document start "---"  (document-start)
  13:3      error    duplication of key "build" in mapping  (key-duplicates)
  25:19     error    syntax error: mapping values are not allowed here

When I add colons to the entry on lines 25 and 28:

workflows:
  version: 2
  minimal:
    jobs:
      - build
      - tests:
          requires:
            - build
      - release:
          requires:
            - tests
          filters:
            tags:
              only: /^v.*$/

...the syntax error is no longer reported:

1:1       warning  missing document start "---"  (document-start)  
13:3      error    duplication of key "build" in mapping (key-duplicates)
0
4

You simply have an incorrect yaml syntax in your workflows jobs list.

From what I could very quickly understand on circleCI's documentation, jobs names are accepted as a shorthand if you don't define any parameters. If you have parameters, the list element is a hashmap with top element being the job name. In your specific case, this should give (note the column after the names of jobs with params):

workflows:
  version: 2
  minimal:
    jobs:
      - build
      - tests:
          requires:
            - build
      - release:
          requires:
            - tests
          filters:
            tags:
              only: /^v.*$/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.