The script available here can be used for this purpose. A slightly modified version of the script to support release pipeline and enable sending any variable name and value for updating a value of a given variable can be found here.
Steps of the Script
1. Take in two parameters – VariableName and VariableValue
2. Create header to access REST API with System.AcessToken. You have to enable Allow Scripts to access the OAuth token in each deployment or agent group phase that you intend to use this script.
4. Update the variable value.
5. Update the release using REST API.
You can use this script and execute it with a PowerShell task in your pipeline. Or you can setup a Task group so that you can reuse it as a task in your release pipelines.
In the above example Run Inline PowerShell task available with extension Inline PowerShell is used. Notice the usage of Variable name and Variable value surrounded with ‘ when passing parameters to avoid argument errors you may encounter if you use them without ‘, specially for variable value.
-VariableName '$(VariableName)' -VariableValue '$(VariableValue)'
Task group can be used as shown below to set a variable value so that it is available to other stages in the release pipeline.
No comments:
Post a Comment