How to access parent's build number in Drone.IO when triggering a forked build using deployment hook?

868 Views Asked by At

I'm trying to build a CI pipeline with drone.io.

The steps are:

  • Build a docker image
  • Tag the docker image with the drone_build_number
  • Deploy the image to the staging environment, "ECS, please deploy myimage:drone_build_number"

The deployment triggers some tests in the staging environment. If these pass, the drone.io's deployment hook is called: http://mydronehost/builds/123?fork=true&event=deployment&deploy_to=prod. This should deploy myimage:drone_build_number to prod, where build_number was 123 in this case. Instead, the build gets a new number, e.g. 124, and the deployment fails, since myimage:124 does not exist.

Is it possible to somehow access the "parent" build-number (123) in this context?

2

There are 2 best solutions below

1
On BEST ANSWER

Why not tag the image with the git commit SHA so it'll be consistent between repeated builds of the same release and across environments?

0
On

When you promote a build you can access the parent build number using the DRONE_BUILD_PARENT environment variable.