I have a task group that contains two tasks: one is a PowerShell script that fetches a value, and the second is an "Azure Functions" task that deploys a function. I would like to use the value from the first task in the second task (as an app setting).
My PowerShell script is of the form:
$result = GetSomeResult();
"##vso[task.setvariable variable=Foo;]$Result";
If this were called directly from a release pipeline, rather than within a task group, this would write the contents of $result
into the pipeline variable $Foo
. I would then be able to use it in other tasks of the pipeline (in this case, the App settings field of the Azure Functions task) as $(Foo)
.
When it is in a task group, however, it does not appear to set the pipeline variable. Instead, it sets an environment variable. I can access it using another PowerShell script via $env:Foo
, but I can't work out how to use it from a normal task.
So my question is how can I use the result of the PowerShell script in the Azure Functions task if they are both in a task group?
how can I use the result of the PowerShell script in the Azure Functions task if they are both in a task group?
You can try the following settings in Task Group.
PowerShell task:
Script:
$result = GetSomeResult();
echo "##vso[task.setvariable variable=Foo;isOutput=true]$Result"
Azure Function Task:
Set the Default value to the variable Foo: $(foo)
Result: