2.1 YAML processing bug


#1

I write .circleci/config.yml like this,

version: 2.1

jobs:
  build:
    executor: default
    steps:
      - run:
          no_output_timeout: 1200
          command: >
            bundle exec rspec --profile 10
                              --format RspecJunitFormatter
                              --out test-results/rspec/results.xml
                              --format html
                              --out artifacts/rspec/results.html
                              --format progress
                              $(circleci tests glob "spec/**/**/*_spec.rb" | circleci tests split --split-by=timings)

and processed yml is here

version: 2
jobs:
  build:
    steps:
    - run:
        no_output_timeout: 1200
        command: |
          bundle exec rspec --profile 10
                            --format RspecJunitFormatter
                            --out test-results/rspec/results.xml
                            --format html
                            --out artifacts/rspec/results.html
                            --format progress
                            $(circleci tests glob "spec/**/**/*_spec.rb" | circleci tests split --split-by=timings)

the point is that
command: > is converted to command: | .

> changes line-brakes to whitescpaces,
but | does not.

Local Circleci CLI behave as same as this. ( $ ciecleci config process )

It seems a bug for me.
thoughts?


#2

Hi there, this looks like it’s not a bug.

If you use the yaml folding indicator >, it will only fold away newlines when two adjacent lines have the same level of indentation.

This snippet is likely what you’re looking for:

echo "
version: 2.1

jobs:
  build:
    machine: true
    steps:
      - run:
          no_output_timeout: 1200
          command: >
            bundle exec rspec --profile 10
            --format RspecJunitFormatter
" | circleci config process -
__bp_preexec_invoke_exec "$_"
__bp_preexec_invoke_exec "$_"
version: 2
jobs:
  build:
    machine: true
    steps:
    - run:
        no_output_timeout: 1200
        command: |
          bundle exec rspec --profile 10 --format RspecJunitFormatter
workflows:
  version: 2
  workflow:
    jobs:
    - build

# Original config.yml file:
#
# version: 2.1
#
# jobs:
#   build:
#     machine: true
#     steps:
#       - run:
#           no_output_timeout: 1200
#           command: >
#             bundle exec rspec --profile 10
#             --format RspecJunitFormatter

This snippet only has one extra space of indentation on the --format line, but that’s enough to disable the > folding behavior:

echo "
version: 2.1

jobs:
  build:
    machine: true
    steps:
      - run:
          no_output_timeout: 1200
          command: >
            bundle exec rspec --profile 10
             --format RspecJunitFormatter
" | circleci config process -
__bp_preexec_invoke_exec "$_"
__bp_preexec_invoke_exec "$_"
version: 2
jobs:
  build:
    machine: true
    steps:
    - run:
        no_output_timeout: 1200
        command: |
          bundle exec rspec --profile 10
           --format RspecJunitFormatter
workflows:
  version: 2
  workflow:
    jobs:
    - build

# Original config.yml file:
#
# version: 2.1
#
# jobs:
#   build:
#     machine: true
#     steps:
#       - run:
#           no_output_timeout: 1200
#           command: >
#             bundle exec rspec --profile 10
#              --format RspecJunitFormatter

You can compare the results of the following with an online yaml parser.

I expected folding of newlines and indentations in your original code, but it looks like the yaml spec specifically has examples to illustrate this is intended.