Andrew Harry

andrewharry.com

Accessing Group Variables in

Azure DevOps

Adding a Toggle in multiple Pipelines

Today, I needed to disable a build step in my yaml file at work. It should have been simple.
But I figured “if i’m going to change it, might as well make a variable for next time”.
This changes was going to be across multiple similar build pipelines with separate yaml definitions.

So in order to add this variable, I was going to add it to an existing “Variable Group”. This way I can toggle the feature on/off from the one place.

It should have been simple

A couple of hours later and after lots of failed attempts - I got something working the way I wanted.

Programming is full of these moments.

  • It should have been simple.
  • Something isn’t quite documented.
  • You’ve burned more hours than you expected
  • Do you give up and walk away?

Do you give up?

I’m not great at calling quits on these issues and maybe that’s not a great thing.
Sometimes, it’s worth digging in and making that almost heroic extra effort to get that thing DONE

I was close to giving up…

The Problem.

The problem is pretty simple, but I was misled by the existing yaml file which had “already working” examples. It turns out the existing examples weren’t actually working!

Had I just googled it, I probably wouldn’t have chased my tail for so long and I might have found a good example online.

But, I didn’t. As I recall, I found lots of non working examples (looking at you stackoverflow).

Maybe the problem I was trying to solve was a bit different or unique, who knows. I’m tired and I’m just glad I got something working…

The Solution

This was the example which helped me from the Azure Docs.

variables:
- group: Shared Group Settings

steps:
- script: DoSomething
  condition: eq(variables['IsEnabled'], true)

Simple.

Done.

Goodnight.

Contents