1
votes

With Azure Release Pipeline, in a task using the PowerShell Script, I am able to set values of variables and pass to next task using the command

Write-Host '##vso[task.setvariable variable=varResourceExists;isOutput=true;something'

However, when I put this similar command in a task that uses Azure PowerShell, this command is no longer allowed, the task produces a warning:

2019-10-22T00:23:14.3080614Z ##[warning]'##vso[task.setvariable variable=varResourceExists;isOutput=true;something' contains logging command keyword '##vso', but it's not a legal command. Please see the list of accepted commands: https://go.microsoft.com/fwlink/?LinkId=817296

As a result, the variable varResourceExists cannot be set by my task. I have also tried a conventional PowerShell set value by doing

$varResourceExists = 'something'; # this also does not work

Is there a way I can set this value in Azure Powershell script so that the next task can reference it?

2

2 Answers

3
votes

##vso[task.setvariable variable=varResourceExists;isOutput=true;something is not correct syntax. You're missing a closing ].

It should be ##vso[task.setvariable variable=varResourceExists;isOutput=true;]something

0
votes

Here is how I solved my topic. In the pipeline Azure PowerShell task, I can have code such as Write-Host '##vso[task.setvariable variable=varResourceExists;isOutput=true;]False';

In the Output Variable option, I set a Reference Name "step1": Output Variable Then in the next step, I can do a conditional check using a Custom Condition: Custom Condition

I can also reference the variable in my code such as Write-Host "The step1.varResourceExists says: $(step1.varResourceExists)";