Yes my first guess when encountering this issue is that is probably related to my developer environment text editor or something like that. Obviously you would be pretty confident yaml parsing works…
In any case hopefully we can figure out workaround/cause and just leave a FAQ for others.
I played multiple times with files either cat’ed in, edited from neovim, or edited from gitlab web ide. All have the problem. At the same time, with drone-yaml
and drone-runtime
I obtain correct results.
I added a bit of sleep to my pipeline so I could check the config map created, for example for the source (at some point I thought I could interjecting steps wtff that fix previous bad lines lol):
With
---
kind: pipeline
name: default
steps:
- name: bar
image: ubuntu:18.04
commands:
- sleep 120
- apt update > /dev/null 2>&1
- echo wtff
- apt install -y curl > /dev/null 2>&1
- echo wtff
- curl -s icanhazip.com
- echo foo
produces
"data": {
"ywmfsxd2cfcfyuyi6r9ik72a02dh260u": "\nif [ -n \"$CI_NETRC_MACHINE\" ]; then\ncat \u003c\u003cEOF \u003e $HOME/.netrc\nmachine $CI_NETRC_MACHINE\nlogin $CI_NETRC_USERNAME\npassword $CI_NETRC_PASSWORD\nEOF\nchmod 0600 $HOME/.netrc\nfi\nunset CI_NETRC_USERNAME\nunset CI_NETRC_PASSWORD\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nset -e\n\necho + \"sleep 120\"\nsleep 120\n\necho + \"apt updat\"\napt updat\n\n"
},
Which ends with “apt updat”.
Another CM I grabbed looked like:
With
---
kind: pipeline
name: default
steps:
- name: bar
image: ubuntu:18.04
commands:
- apt update > /dev/null 2>&1
- echo wtff
- apt install -y curl > /dev/null 2>&1
- echo wtff
- curl -s icanhazip.com
- echo foo
"data": {
"zhpe0yauxodxdct2rgymk8ycofn1o6mf": "\nif [ -n \"$CI_NETRC_MACHINE\" ]; then\ncat \u003c\u003cEOF \u003e $HOME/.netrc\nmachine $CI_NETRC_MACHINE\nlogin $CI_NETRC_USERNAME\npassword $CI_NETRC_PASSWORD\nEOF\nchmod 0600 $HOME/.netrc\nfi\nunset CI_NETRC_USERNAME\nunset CI_NETRC_PASSWORD\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nset -e\n\necho + \"apt update \u003e /dev/null 2\u003e\u00261\"\napt update \u003e /dev/null 2\u003e\u00261\n\necho + \"echo wtff\"\necho wtff\n\necho + \"apt install -y curl \u003e /dev/null\"\napt install -y curl \u003e /dev/null\n\n"
},
With
---
kind: pipeline
name: default
steps:
- name: bar
image: ubuntu:18.04
commands:
- sleep 120
- "apt update > /dev/null 2>&1"
- echo wtff
- "apt install -y curl > /dev/null 2>&1"
- echo wtff
- curl -s icanhazip.com
- echo foo
get
"data": {
"0woesptn9e1011nff28wdtecm4ihlt6j": "\nif [ -n \"$CI_NETRC_MACHINE\" ]; then\ncat \u003c\u003cEOF \u003e $HOME/.netrc\nmachine $CI_NETRC_MACHINE\nlogin $CI_NETRC_USERNAME\npassword $CI_NETRC_PASSWORD\nEOF\nchmod 0600 $HOME/.netrc\nfi\nunset CI_NETRC_USERNAME\nunset CI_NETRC_PASSWORD\nunset DRONE_NETRC_USERNAME\nunset DRONE_NETRC_PASSWORD\nset -e\n\necho + \"sleep 120\"\nsleep 120\n\necho + \"apt update \u003e /dev/null 2\u003e\u00261\"\napt update \u003e /dev/null 2\u003e\u00261\n\necho + \"echo wtff\"\necho wtff\n\necho + \"apt install -y curl \u003e /dev/null 2\u003e\u00261\"\napt install -y curl \u003e /dev/null 2\u003e\u00261\n\necho + \"echo wtff\"\necho wtff\n\necho + \"curl -s icanhazip.com\"\ncurl -s icanhazip.com\n\necho + \"echo fo\"\necho fo\n\n"
},
Which is functional, just drops last character of last step.
Adding the
...
at the end removes the last step having its last character removed.
Looks like if I follow perfect yaml format, it works:
---
kind: pipeline
name: default
steps:
- name: bar
image: ubuntu:18.04
commands:
- sleep 120
- "apt update > /dev/null 2>&1"
- echo wtff
- "apt install -y curl > /dev/null 2>&1"
- echo wtff
- curl -s icanhazip.com
- echo foo
...
Does Drone internally run drone-yaml fmt
first?
Seems like problem is centered around incorrect yaml parsing when not using “—” + “…” and not wrapping steps with special characters (> is special?) with ".
Edit: now getting a bunch of unexpected end of stream problems when trying to write yaml with ...
at the end. Seems finicky to get accepted. With unexpected end of stream error I can remove " from quoted steps and it works but then goes back to original problem. For some reason that pipeline above with interspersed wtf’s works.
I’m happy to continue digging further. Probably will make more sense to wait for 1.0.0 code to be released though so I can develop against an exact release. For now will just stick to 0.8.x. Can try to prepare a terraform config for launching gitlab+drone on GKE with the problem. Seems like an extremely random problem, and the fact that drone-yaml
and drone-runtime
work on my local machine is curious.