Ash*_*ran 5 azure-devops azure-pipelines azure-pipelines-yaml
我们有一个场景,一旦我们手动取消 Azure DevOps 中的管道,我们需要终止特定进程 (exe)。我们想知道如何在 YAML 取消后触发任务来实现这一目标。
请尝试以下方法:
terminate the particular process (exe)如果管道中有多个作业,请确保在所有其他作业完成处理后处理运行任务的作业( Succeeded、Failed或Canceled)。您可以使用“ dependsOn ”键来设置作业的执行顺序。有关更多详细信息,请参阅“依赖关系”。
然后,如前所述@ShaykiAbramczyk,在作业上terminates the particular process (exe),您可以使用 ' condition' 键指定作业运行的条件。详情请参阅“条件”。
jobs:
. . .
- job: string
dependsOn: string
condition: eq(variables['Agent.JobStatus'], 'Canceled')
Run Code Online (Sandbox Code Playgroud)
如果您的管道中只有一项作业,请确保该任务terminate the particular process (exe)是作业中的最后一步。您需要将此任务放在该作业的步骤列表的底部。
然后还需要指定任务的条件为terminate the particular process (exe)。
如果在此步骤上使用“ condition”键,则无论是否跳过该步骤,该步骤将始终列出并显示在作业运行中。
steps:
- step: string
condition: eq(variables['Agent.JobStatus'], 'Canceled')
Run Code Online (Sandbox Code Playgroud)
if如果在步骤上使用“ ”语句,则仅当if满足“ ”条件并运行该步骤时,才会在作业运行中列出并显示该步骤。如果不满足条件并跳过该步骤,则该步骤将隐藏在作业运行中。
steps:
- ${{ if eq(variables['Agent.JobStatus'], 'Canceled') }}:
- step: string
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2652 次 |
| 最近记录: |