YAML multiline strings

Hi all.

I’m facing a weird behavior related with multiline YAML strings. I have a configuration file similar to the following:

before_install:
  - sudo apt-get update
  - >
    sudo apt-get install -y
    dependency-1
    dependency-2

...

after_success:
  - >
    run_test.sh
      arg
      --flag-1
      --flag-2

The commands in the before_install step are rendered fine (including the folded multiline YAML string)

# sudo apt-get update
...
# sudo apt-get install -y dependency-1 dependency-2

However, the multiline string in the after_success step is not render properly:

# run_test.sh
...
--arg: command not found
--flag-1: command not found
--flag-2: command not found

It seems like the multiline strings works in before_install but not in after_success.

Any ideas?

Related info: https://yaml-multiline.info/

Build output:

Step command:
https://travis-ci.org/superruzafa/visual-scala-reference/builds/550692201#L3807

CLI errors:
https://travis-ci.org/superruzafa/visual-scala-reference/builds/550692201#L9191

When reporting a problem, please include a build URL that shows the issue. Thanks.

Sorry, I included links to the build output.

I guess I found the cause: The multiline string is rendered correctly only if all the lines start at the same column than the first one:

Wrong

after_success:
  - >
    run_test.sh
      arg
      --flag-1
      --flag-2

Good

after_success:
  - >
    run_test.sh
    arg
    --flag-1
    --flag-2

I don’t know if this is part of the YAML spec. In other projects I used several levels of indentation without problems in multiline strings.

With extra spaces, your multiline strings have newlines (as well as the white spaces you used in indentation):

after_success:
  - >
    run_test.sh
      arg
      --flag-1
      --flag-2

is in JSON:

{
  "after_success": [
    "run_test.sh\n  arg\n  --flag-1\n  --flag-2"
  ]
}