.drone.yml parsing fails when colons in array strings

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:

  image: docker
     - DOCKER_HOST=tcp://docker:2375
     - MINECRAFT_VER=1.12.1
    - 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

yaml marshal and unmarshal is handled by 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 :frowning:

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?

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

    image: alpine
        - |
          if [[ -f /drone ]]; then
          touch /drone/test
        - ls /drone
1 Like

This also works:

    - >
      docker build --target test 
      --tag example/app:test ./app