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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With