My drone.yml file has the following references to the secrets which I am trying to write to the .env file. Howeverm for some unknown reason, the variables appear to be empty and my build is failing because of undefined values.
I made sure that the values are present in the secrets section declared.
secrets : [docker_xyz]
commands:
- echo “docker_xyz =$${docker_xyz}” >> .env
Also I tried the following too:
secrets : [docker_xyz]
commands:
- echo “docker_xyz =${docker_xyz}” >> .env
This is driving me crazy ! Help please !
There are two issues with your yaml.
First is that the syntax you are using for secrets is incorrect. Please see our documentation for the correct syntax to inject secrets as environment variables:
https://docs.drone.io/secret/repository/
Second, please see our documentation for using environment variables and common problems users face. https://docs.drone.io/pipeline/environment/syntax/#common-problems
So my version of drone used it 0.8.x and yea. I figured it out. Our enterprise drone secrets have a documentation confined to the same version and I had to refer that which is entirely different from the latest version of drone in the website.
However, the reference was incorrect (tried different examples all over the internet).
The correct way is using uppercase with a $ sign.
Ex: secrets : [docker_xyz]
commands:
- echo “docker_xyz =${DOCKER_XYZ}” >> .env
And it worked. Thanks for the response.