Set image identifier in one step to be used in another

Hello,

I’m wondering if there’s currently a way to set an environment variable in one pipeline step so that it could be used as the image identifier in another. Concretely, I’m wondering if there’s a way to do the following:

# This step sets the value VAR_FOO
- name: a-step
  image: some/image:latest
...

- name: another-step
  image: an/image/determined/by/foo:$VAR_FOO
...

It would be helpful to run an image whose hash is determined during the drone runtime. Otherwise, I would have to grab that image identifier and run a docker image within another docker image (which I’m trying to avoid).

Thanks!

it is not possible to share variables like this in-between pipelines or pipeline steps. However, one common solution to this problem is to use the commit sha or build number in your image tag name [1][2] or some other combination of metadata.

[1] https://docs.drone.io/pipeline/environment/substitution/
[2] https://docs.drone.io/pipeline/environment/reference/

1 Like