0
votes

I am trying to pass PowerShell variable to an Azure Devops variable in pipeline during runtime but unable to pass them successfully. Could someone guide the correct syntax to apply escape sequence?

Azure devops pipeline variable:-

foo_ABC = abcdefghigklmnopqrstxyz
env= abc

Powershell task in pipeline:-

$environment=  "$(env)".ToUpper()

$temp= "foo_$($environment)"

Write-Output "$($temp)"

Output:-

Expected: abcdefghigklmnopqrstxyz

Actual: (foo_ABC)
1
Did you look at the documentation for how Azure DevOps variables are treated in scripts? Hint: It's an environment variable.Daniel Mann

1 Answers

1
votes

For this issue , the value of nested variables (like $($temp) are not yet supported in the pipelines. You can refer to this case to see this point.

As a workaround, you can try to use the Variable Toolbox task.

enter image description here

enter image description here enter image description here

You can refer to this case for this task.