I’m using drone at cloud.drone.io (not sure what ersion that is) and since today, environment variables are not getting expanded/evaluated any longer when used in the settings of a plugin or as part of the image name.
Here is my step config:
- name: build
image: plugins/docker
settings:
tags: "tst-${DRONE_COMMIT_SHA}"
dockerfile: ./Dockerfile
repo: oliver006/drone-gcf
...
This used to tag and publish the image as expected but not any longer.
Similarly, using
- name: deploy-test-cloud-function-test
image: "oliver006/drone-gcf:tst-${DRONE_COMMIT_SHA}"
now fails with a cryptic invalid reference format
error as it seems to not evaluate/expand the env variable any longer.
Did any change? Do I need to do something different when using the env variables?
sorry, I am unable to reproduce. I created a branch to test [1] and everything was working as expected [2]. You can find the yaml substitution source code on github [3][4] it you are interested in auditing the code further.
for quick reference, here is the yaml I used:
kind: pipeline
name: default
steps:
- name: build
image: plugins/docker
settings:
repo: hello-world-${DRONE_COMMIT_SHA}
tags: latest
dry_run: true
and in the build logs I see this (commit sha in repository name) which demonstrates that the substitution worked:
+ /usr/local/bin/docker tag bc774c56e008f6134c4debaa80fcc932adcd00f4
hello-world-56e008f6134c4debaa80fcc932adcd00f4:latest
[1] https://github.com/drone/hello-world/commits/test-yaml-subst
[2] https://cloud.drone.io/drone/hello-world/36/1/2
[3] https://github.com/drone/drone/blame/master/operator/runner/runner.go#L186:L192
[4] https://github.com/drone/envsubst
My bad, I must have messed up something pretty badly with my .drone.yml file. I created the file from scratch and it now works, not really sure what it was but it’s all good now, thanks for your quick help!
ok great, glad to hear that you got it working
I figured out what triggered the issue. Somewhere, way down in the drone.yml file, i accidentally used ${$DRONE_TAG}
(note the extra $
inside the { ... }
).
This would completely mess up any sort of DRONE_ env variable substitution in all other steps in the drone file.
No idea why but I figured I’d update this thread in case someone else stumbles upon this.