Following the thread in Trigger downstream and the implementation in drone-downstream, I want to start a new build with a specific parameter. I start by getting the latest build available for the branch.
curl -s -X POST -H "Authorization: Bearer ${SERVICE_TOKEN}" "https://{server}/api/repos/{owner}/{repo}/builds/$BUILD?IMAGE_TAG=deadbeef&fork=true"
I get a new build, but the parameter isn’t available in the pipeline either specified in the environment or within the commands:
build:
image: myimage
environment:
- IMAGE_TAG=${IMAGE_TAG} # tried specifying here
commands:
- echo ${IMAGE_TAG} # this is always blank
- IMAGE_TAG=${IMAGE_TAG} # also tried specifying here without the environment declaration and above command
- echo $IMAGE_TAG # this is always blank
Can someone point me in the right direction to get this working? Thanks!
I spun up Drone 0.8.1, and am experiencing the same issue with parameters not being available in the environment of the triggered build. Any further help and ideas would be very much appreciated!
If I understand correctly you are trying to interpolate custom build variables in the yaml. These values are passed to your container as environment variables, but cannot be interpolated in the yaml.
If we look at your example …
environment:
ENV_PARAM=${PARAM1=undefined}
The above line would not work because PARAM1 is not available to the yaml pre-process for substitution. It is also unnecessary because PARAM1 is already available to your container as an environment variable.
The practice of interpolating environment variables in the environment section was required for older versions of drone (pre 0.6) but is no longer required since these variables are already available to your environment.
I also wanted to provide some additional detail. I ran a quick test to confirm custom parameters are being passed to the pipeline as environment variables. I ran the following command to trigger a build:
Yes, thank you! I see that I didn’t understand that the build parameters were available directly as environment variables, instead of being available as part of the interpolation. Thanks for clearing that up!