Azure Devops Pass Variables between Tasks

Posted by

Today I wanted to see if it was possible to create a variable in Azure Devops, change the value within a Task and then use the updated value in a step further down the list of Tasks.

 

Turns out its pretty easy (when you get the syntax correct)


So I created a variable in Azure Devops called Version like so and set its value to 1.0

 

 

 

And then I want to make sure I can read this from a standard PowerShell Task in a step within my Build like so :-

Which when built showed me the value as I’d expect of 1.0

And then I want to set the variable to a new value (which could be from anything or anywhere to be honest) using the syntax

##vso[task.setvariable variable=Version]1.2.3

And then finally read out the current value by using $(Version)

Which shows the Version parameter has been updated to 1.2.3 as we would want.

Hope this helps someone at some point 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s