# YAML multiline strings

**URL:** <https://travis-ci.community/t/yaml-multiline-strings/3914>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** config, yaml\
**Created:** [June 26, 2019, 9:13am UTC](https://travis-ci.community/t/yaml-multiline-strings/3914 "2019-06-26T09:13:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![superruzafa](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/superruzafa/32/2088_2.png) [@superruzafa](https://travis-ci.community/u/superruzafa)\
**Post date:** [June 26, 2019, 9:13am UTC](https://travis-ci.community/t/yaml-multiline-strings/3914/1 "2019-06-26T09:13:42Z")

</div>

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/](https://yaml-multiline.info/)

**Build output:**

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

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

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [June 26, 2019, 11:43am UTC](https://travis-ci.community/t/yaml-multiline-strings/3914/2 "2019-06-26T11:43:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![superruzafa](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/superruzafa/32/2088_2.png) [@superruzafa](https://travis-ci.community/u/superruzafa)\
**Post date:** [June 26, 2019, 1:05pm UTC](https://travis-ci.community/t/yaml-multiline-strings/3914/3 "2019-06-26T13:05:14Z")

</div>

Sorry, I included links to the build output.

---

<div class="post-metadata">

**Author:** ![superruzafa](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/superruzafa/32/2088_2.png) [@superruzafa](https://travis-ci.community/u/superruzafa)\
**Post date:** [June 26, 2019, 1:08pm UTC](https://travis-ci.community/t/yaml-multiline-strings/3914/4 "2019-06-26T13:08:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [June 26, 2019, 1:30pm UTC](https://travis-ci.community/t/yaml-multiline-strings/3914/5 "2019-06-26T13:30:28Z")

</div>

> [@superruzafa](#):
>
> 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):

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

```

is in JSON:

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

```
