限制在 Azure DevOps Step 中使用的变量分组

Restrict variable grouping being used in Azure DevOps Step

我有两个具有重叠键但值不同的变量组。我想在一项任务 [JSON 替换 ] 下使用一个组,在另一个任务 [JSON 替换 ] 中使用另一组。 我试过阅读文档,它说变量只能设置在 root/stage/job 级别。我有办法解决这个问题吗?

I want to use one group under one task [ JSON replace ] and the other group in another [JSON replace ].

根据文献Specify jobs in your pipeline,我们可以知道:

You can organize your pipeline into jobs. Every pipeline has at least one job. A job is a series of steps that run sequentially as a unit. In other words, a job is the smallest unit of work that can be scheduled to run.

并且变量组会作为预选条件添加到预编译审核阶段,我们无法在任务级别re-set

要解决此问题,您可以通过 Logging Command:

覆盖指定变量
Write-Host "##vso[task.setvariable variable=testvar;]testvalue"