我想要这样的东西:
- ${{ if or(eq(parameters.RunTestsOnPRBuildOnly, false), eq(variables.Build.Reason, 'PullRequest')) }}:
- template: ps-module-run-tests.yml
这不起作用,因为variables.Build.Reason
是空的。有可能吗?
请注意,我知道如何修改ps-module-run-tests.yml
模板来表达我的愿望作为运行时条件。换句话说,我知道如何实现这一点:
我好奇的是是否Build.Reason
可以在编译时条件下使用,这样这些步骤甚至不会被渲染。从表面上看,这并没有固有的问题,因为该值在开始时就已知,但这取决于模板的编译时间。如果太早的话,那是不可能的,但我不知道这些细节。也许我做不到,因为我错过了一些东西。
那么,有可能吗?
代替
variables.Build.Reason
尝试使用
variables['Build.Reason']
根据Build.Reason 在编译时可在模板表达式中使用
I have looked at https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion there is one example also there is note that if you want to use property dereference syntax it can contain only
and so dot sign is not acceptable (dot between Build and Reason)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)