8

I am using a variables.yml file as a template to store different variables, and I was curious if I am able to reference variables within the yml file itself to essentially nest them.

For example:

#variables.yml file
variables:
  food1:        'pineapple'
  food2:        'pizza'
  favoriteFood: '$(food1) $(food2)'

So that when I eventually call upon this variable "favoriteFood", I can just use ${{ variables.favoriteFood }} and the value should be "pineapple pizza" Example:

#mainPipeline.yml file
variables: 
-  template: 'variables.yml'
steps: 
-  script: echo My favorite food is ${{ variables.favoriteFood }}.

Am I on the right track here? I can't seem to google to any examples of if this is possible.

aseb
  • 274
  • 2
  • 11
  • Did you try it? – Daniel Mann May 11 '21 at 21:33
  • Yes I did try it and thought it wasn't possible, but it is in fact possible as long as you follow the syntax i have above. I missed some values which is why it wasnt working. Fixed now! – aseb May 11 '21 at 21:43

1 Answers1

3

Yes! It is in fact possible, just follow the syntax outlined above. Don't forget spacing is critical in YML files.

aseb
  • 274
  • 2
  • 11