如何在任务成功后通过“输出变量”部分或 Azure devops 中的其他方法更新管道变量

How to update a pipeline variable after the task is succeeded, through `output variable` section or some other method in Azure devops

我想在任务完成后更新管道变量。我可以通过 azure DevOps 中提供的输出变量部分来完成吗?

主要objective是为了让下游的任务知道前面具体的任务列表已经成功了,我可以通过添加自定义条件来查看

如果你的任务是在agent job中,则不需要使用output variable部分,只需要在任务成功后添加一个Powershell任务,即可overwrite/update变量的值通过使用 logging command 在 Azure Devops 管道中再次设置变量。

Write-Host "##vso[task.setvariable variable={variableName}]{updateValue}"

要从脚本设置变量,请使用 task.setvariable 日志命令。这不会更新环境变量,但它确实使新变量可用于同一作业中的下游步骤。另外,这里有一个reference.