Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do pass variables between tasks in VSTS pipeline?

Im working on deploying arm templates via VSTS pipeline. I have a powershell script which gets a subnet id and I need to pass this subnet id value into another task in VSTS. How can i pass variables from a powershell script to vsts and then pass this to azure resource group deployment task as a parmaeter?

like image 524
itye1970 Avatar asked Mar 13 '18 08:03

itye1970


1 Answers

You can set a new variable in your powershell and then pass it to VSTS, so that it can be used in one of the next tasks, like this.

Write-Host "##vso[task.setvariable variable=sauce]crushed tomatoes"
Write-Host "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"

This will create a new environment variable called 'sauce' (first example) with value 'crushed tomatoes'.

On your next task you can read it using $(sauce) in your task configuration screen or $env:sauce in a powershell script.

See https://docs.microsoft.com/en-us/vsts/build-release/concepts/definitions/release/variables?tabs=batch for more info about how to use it.

like image 98
Rodrigo Werlang Avatar answered Nov 15 '22 14:11

Rodrigo Werlang