I just spent a couple of hours troubleshooting why this .drone.yml
would not compile:
---
kind: pipeline
name: build
steps:
# Make sure image builds
- name: build
image: katharostech/drone-kaniko
trigger:
ref:
exclude:
- refs/tags/v*
branch:
exclude:
- feature/*
---
kind: pipeline
name: release
steps:
# Release image to Docker Hub
- name: release
image: katharostech/drone-kaniko
settings:
repo: katharostech/mysql-backup
tags: ${DRONE_TAG}, latest
username:
from_secret: docker-username
password:
from_secret: docker-password
when:
ref:
- refs/tags/v*
trigger:
event:
- tag
ref:
- refs/tags/v*
It would fail with the message:
build: yaml: line 9: did not find expected node content
It turns out that the tags
setting needed to have quotes around it like so
...
steps:
# Release image to Docker Hub
- name: release
image: katharostech/drone-kaniko
settings:
repo: katharostech/mysql-backup
tags: "${DRONE_TAG}, latest"
username:
from_secret: docker-username
password:
from_secret: docker-password
when:
ref:
- refs/tags/v*
...
Quotes are not usually needed in yaml for anything that is apparently not any other type, but for some reason Drone has a problem in the case of variable expansion. Additionally, it doesn’t have any problems if you just use ${DRONE_TAG}
as the tags
value. The only time it has problems is when you combine variable expansion with other text in the same setting.
Also, the bug is somewhat elusive because it only seems to happen when there are multiple pipelines as well ( I think ). It took me so long to find what was causing it because there would be strange cases where it would work.
I’m not sure if this counts as a bug or not, but either way this could be good for somebody else to know.