I have a drone.yml that has multiple docker pipelines, and all of them have several steps that use the same image more than once. Instead of writing every single time:
- name: name_of_step
image: name_of_image_written_manually
I want to declare a variable at the very top of the file so it can be updated much more easily in the future when new versions come out.
Right now I have the variable declaration like this:
variables:
name_of_image: name_of_image_written_manually
kind: pipeline
type: docker
{rest of file}
But the problem arises when trying to use the variable. I've tried: image: $name_of_image
, image: ${name_of_image}
, image: ${{ name_of_image }}
, image: ${{ variables.name_of_image }}
. But I keep getting errors like 'invalid reference format'
, 'unable to parse variable name'
, and 'linter: invalid or missing image'
.
I've tried to look for documentation but can't find a reliable answer for my specific case. I'm not even sure whether the problem is the variable declaration or the syntax of the variable use. For the variable declaration I've also tried:
global-variables:
name_of_image: name_of_image_written_manually
and
variables:
- name: name_of_image
value: name_of_image_written_manually
Any help would be appreciated. Thanks in advance!