Tag wrongly gets parsed as octal
Closed this issue · 2 comments
Plugin step configuration:
- name: build-docker
image: plugins/docker
settings:
username:
from_secret: docker-username
password:
from_secret: docker-password
repo: registry.gitlab.com/${DRONE_REPO}
registry: registry.gitlab.com
tags:
- ${DRONE_COMMIT_SHA:0:7}
- ${DRONE_TARGET_BRANCH}
${DRONE_COMMIT_SHA:0:7}
resolves to 0351500
in the run where we encountered this error. Resulting Docker command:
/usr/local/bin/docker tag 0351500<the rest of the full commit hash>
registry.gitlab.com/<our repository>:119616
Testing confirms that 0351500
as octal converts to 119616
in decimal. This is reproducible with fmt.Println
in Go, but the plugin should sanitize input correctly regardless and parse tags only as strings. Presently, the plugin applies an incorrect tag and breaks the rest of the pipeline, since the resulting image cannot be correctly referenced by the subsequent steps.
You should always quote variables that could start with digits like commit SHAs, than it is correctly handled. AFAIK it's simply a downside of YAML parsing.
Thanks and apologies for the erroneous report in this case. I was not aware of this behaviour from YAML.