AzureDevops - 如何根据依赖于先前代理的自定义条件执行发布管道代理
AzureDevops - How to execute the release pipeline agent based on the custom condition which depends on the previous agent
我的发布管道中有 2 个代理。第二个代理应该 运行 仅基于第一个代理的输出。
第一个代理有以下代码
ssh task:
echo "##vso[task.setvariable variable=isNextExecutable;isOutput=true]true"
第二个代理具有以下自定义条件
and(succeeded(), eq(variables[isNextExecutable], 'true'))
此外,我尝试使用 API 更新环境变量(跟随 )
但是变量正在更新,只有发布管道正在完成。
我的问题:
1)如何根据第一次代理输出的自定义条件执行代理?
2) 是否可以在任务级别添加多个自定义条件?如果前一个任务成功执行并且基于在同一个代理中的前一个任务中设置的一些值,则任务应该执行。
How to execute the agent based on the custom condition based on the
first agent output?
对于这个问题,如果你没有使用yaml发布管道,恐怕这是不可能的。
Note that the updated variable value is scoped to the job being
executed, and does not flow across jobs or stages.
这在官方 document. You can try to create multi stage pipelines with YAML in Azure DevOps , so that you can use multi-job output variables 中说明是为了跨作业传递变量值。
作为解决方法,您可以在发布定义变量中定义一个变量,然后使用 REST API(定义 - 更新)更新代理作业中发布定义变量的值 1,使用在下一个代理作业中发布定义变量的更新值,详情请参考。
Is it possible to add multiple custom condition on the task level?
对于这个问题,答案是是,你只需要使用这样的脚本##vso[task.setvariable variable={variableName};isOutput=true]{variableValue}
输出到下面的任务即可。
在以下任务中:
经过如此多的调试,我发现了我的 PowerShell 脚本中的错误。这可能对其他人有帮助。
在发布管道执行完成后更新发布定义。
https://vsrm.dev.azure.com/{org}/{project}/_apis/Release/definitions**/$(Release.ReleaseId)?api-version=5.1
要在发布管道执行期间更新发布定义,请使用下面的 URL,但这些更改在同一代理中不可用。如果要使用修改后的值,则必须创建一个单独的代理。
https://vsrm.dev.azure.com/{org}/{project}/_apis/release/releases/$(Release.ReleaseId)?api-version=5.1
如果要在任务组中使用变量,可以设置 isOutput=false 并使用表达式 $(变量名)
进行引用
https://github.com/MicrosoftDocs/azure-devops-docs/issues/6983
我的发布管道中有 2 个代理。第二个代理应该 运行 仅基于第一个代理的输出。
第一个代理有以下代码
ssh task:
echo "##vso[task.setvariable variable=isNextExecutable;isOutput=true]true"
第二个代理具有以下自定义条件
and(succeeded(), eq(variables[isNextExecutable], 'true'))
此外,我尝试使用 API 更新环境变量(跟随
我的问题:
1)如何根据第一次代理输出的自定义条件执行代理?
2) 是否可以在任务级别添加多个自定义条件?如果前一个任务成功执行并且基于在同一个代理中的前一个任务中设置的一些值,则任务应该执行。
How to execute the agent based on the custom condition based on the first agent output?
对于这个问题,如果你没有使用yaml发布管道,恐怕这是不可能的。
Note that the updated variable value is scoped to the job being executed, and does not flow across jobs or stages.
这在官方 document. You can try to create multi stage pipelines with YAML in Azure DevOps , so that you can use multi-job output variables 中说明是为了跨作业传递变量值。
作为解决方法,您可以在发布定义变量中定义一个变量,然后使用 REST API(定义 - 更新)更新代理作业中发布定义变量的值 1,使用在下一个代理作业中发布定义变量的更新值,详情请参考
Is it possible to add multiple custom condition on the task level?
对于这个问题,答案是是,你只需要使用这样的脚本##vso[task.setvariable variable={variableName};isOutput=true]{variableValue}
输出到下面的任务即可。
在以下任务中:
经过如此多的调试,我发现了我的 PowerShell 脚本中的错误。这可能对其他人有帮助。
在发布管道执行完成后更新发布定义。
https://vsrm.dev.azure.com/{org}/{project}/_apis/Release/definitions**/$(Release.ReleaseId)?api-version=5.1
要在发布管道执行期间更新发布定义,请使用下面的 URL,但这些更改在同一代理中不可用。如果要使用修改后的值,则必须创建一个单独的代理。
https://vsrm.dev.azure.com/{org}/{project}/_apis/release/releases/$(Release.ReleaseId)?api-version=5.1
如果要在任务组中使用变量,可以设置 isOutput=false 并使用表达式 $(变量名)
进行引用https://github.com/MicrosoftDocs/azure-devops-docs/issues/6983