【发布时间】:2021-03-26 21:00:57
【问题描述】:
我正在学习使用 azure devop 的 yaml 管道。
在一个阶段,我把这个条件放在
condition: and(succeeded(), eq(variables['System.PullRequest.PullRequestId'], 'Null')
variables:
prId: $(System.PullRequest.PullRequestId)
reason: $(Build.Reason)
基本上只在不是拉取请求时才运行此阶段。但是,当我手动触发管道时,azure devop 决定跳过此操作。所以我添加了构建原因和 pullrequestId 作为变量然后输出它。
write-host "------------------------------"
write-host '$(reason)'
write-host "------------------------------"
write-host '$(prId)'
输出是:
Manual
$(System.PullRequest.PullRequestId)
我在想,当它不是由 PullRequest 触发时,$(System.PullRequest.PullRequestId) 应该为 null 或空字符串。看起来情况并非如此。文档说 PullRequestId 只有在拉取请求时才会被填充,但我真的不知道没有填充时的值是什么。至少看起来不是 Null。
那么除了 PullRequestId 之外,构建原因是 PR 或非 PR 运行之间不同的可靠条件吗?
【问题讨论】:
标签: azure-devops azure-devops-yaml