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
3. Get the current release using the ReleaseID.
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.