# .drone.yml parsing fails when colons in array strings

**URL:** <https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395>\
**Category:** Drone Support\
**Created:** [September 13, 2017, 8:44pm UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395 "2017-09-13T20:44:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![frebib](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frebib/32/2454_2.png) [@frebib](https://drone.discourse.group/u/frebib)\
**Post date:** [September 13, 2017, 8:44pm UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395/1 "2017-09-13T20:44:34Z")

</div>

Whilst writing CI for our minecraft image, we seem to have come across a YAML parsing bug.  
This is an excerpt of the test stage from the .drone.yml file:

```
test:
  image: docker
  environment:
     - DOCKER_HOST=tcp://docker:2375
     - MINECRAFT_VER=1.12.1
  commands:
    - apk add --no-cache curl
    - docker run --name=DEV -d devbuild /bin/sh < mc-test.sh
    - timeout -t 30 /bin/sh -c 'docker logs --tail="all" -f DEV | grep -qe "[Server thread/INFO]: Done ([0-9]\+\.[0-9]\+s)\!"'

```

When running this config in drone, or using `drone exec` a parsing error is spat out:

```
2017/09/13 21:36:05 Cannot unmarshal 'map[timeout -t 30 /bin/sh -c 'docker logs --tail="all" -f DEV | grep -qe ":Done ([0-9]\+\.[0-9]\+s)\!"']' of type map[interface {}]interface {} into a string value

```

indicating that the array value is invalid.

It turns out to be caused by the `[..]:` part from within the double-nested brackets.  
Escaping the space after this seems to resolve the issue

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [September 13, 2017, 10:41pm UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395/2 "2017-09-13T22:41:30Z")

</div>

yaml marshal and unmarshal is handled by [https://github.com/go-yaml/yaml](https://github.com/go-yaml/yaml)

Unfortunately this is not something we control or could resolve at the drone level. I would suggest creating an issue for the library author, but the project has been slow to fix issues and merge pull requests ☹

---

<div class="post-metadata">

**Author:** ![frebib](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/frebib/32/2454_2.png) [@frebib](https://drone.discourse.group/u/frebib)\
**Post date:** [September 14, 2017, 10:06pm UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395/3 "2017-09-14T22:06:46Z")

</div>

Strangely enough, vim’s syntax highlighting also picks up on this as being correct behaviour when using some permutations of quotations so whilst it causes some head-scratching I’m putting this down to a non-issue.

Maybe, however, it would be useful to include a section in the documentation to cover this?

---

<div class="post-metadata">

**Author:** ![Sharsie](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sharsie/32/3638_2.png) [@Sharsie](https://drone.discourse.group/u/Sharsie)\
**Post date:** [September 15, 2017, 2:45am UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395/4 "2017-09-15T02:45:24Z")

</div>

It seems a block style command unmarshals properly as well, I am not sure about your exact use case, but running a pipeline with nested brackets works for me… something along the lines of

```auto
  test:
    image: alpine
      commands:
        - |
          if [[-f /drone]]; then
          touch /drone/test
          fi
        - ls /drone
```

---

<div class="post-metadata">

**Author:** ![ivorscott](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/ivorscott/32/5254_2.png) [@ivorscott](https://drone.discourse.group/u/ivorscott)\
**Post date:** [July 27, 2019, 7:58am UTC](https://drone.discourse.group/t/drone-yml-parsing-fails-when-colons-in-array-strings/11395/5 "2019-07-27T07:58:49Z")

</div>

This also works:

```
 commands: 
    - >
      docker build --target test 
      --file="./app/Dockerfile"
      --tag example/app:test ./app

```

[https://yaml-multiline.info/](https://yaml-multiline.info/)
