Azure DevOps 管道表达式

时间:2021-01-11 11:02:40

标签: azure-devops azure-devops-extensions azure-pipelines-yaml

目标是根据管道中使用的任务来调节任务自定义扩展。为此,我们想使用 pipelines decorators

例如,如果任何用户在他们的管道中使用 Powershell 任务,我们希望使用装饰器执行我们的任务。

但我们可以弄清楚如何让它发挥作用。

雅姆:

 steps:
 - ${{ if and(eq(resources.repositories['self'].ref, r esources.repositories['self'].defaultBranch), not(containsValue(job.steps.*.task.id, 'd9bafed4-0b18-4f58-968d-86655b4d2ce9'))) }}:
   - script: dir
     displayName: 'Run my script (injected from decorator)'

直接来自 Microsoft tutorial

在 Azure DevOps Pipelines 中,可视化编辑器带来此错误:

 Unexpected property ${{ if containsValue(job.steps.*.task.id, '1c524b9b-9f4d-4897-8f1e-6ec33271d75c') }}

第一个属性必须是任务

在运行时:

error

我们也尝试过 condition() :

condition: |
    and
    (
      eq(dependencies.A.result, 'Succeeded'),
      containsValue(dependencies.A.steps.*.task.id, '1c524b9b-9f4d-4897-8f1e-6ec33271d75c')
    )  

但是我们找不到正确的语法,对象内容为空:

object_null

有谁知道如何检索任务 ID 并使用它来调节任何进一步的任务?

0 个答案:

没有答案