是否可以在 Azure Devops YAML 管道中根据某些变量数据动态创建附加步骤(无需创建我们自己的插件)
问题是我发现我想遍历多个目录,但我不想将所有内容集中在一个步骤中,因为这使得扫描查找错误变得更加困难。
是否可以在Azure Devops YAML管道中动态创建
基于一些可变数据的附加步骤(无需创建我们自己的
插入)
不,Yaml 管道 (azure-pipeline.yml) 受版本控制。所以你想要的(对于你的原始标题)是动态提交对azure-pipeline.yml
执行管道时的文件。这不是推荐的工作流程。
1.相反,你可以考虑使用动态启用/禁用附加步骤。
2.如果您没有使用条件,您可以检查条件模板 https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#parameters-to-select-a-template-at-runtime as Simon上面建议。
此外,#1 和 #2 都可以使用新功能.
3.但是,如果您指的动态变量来自以下结果components = result of ls -1 $(Pipeline.Workspace)/components
命令,上述提示不适用于这种情况。为此,你可以尝试这样的事情:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
# some logic to run `components = result of ls -1 $(Pipeline.Workspace)/components` and determine whether to set the WhetherToRun=true.
'Write-Host "##vso[task.setvariable variable=WhetherToRun]True"'
- task: CmdLine@2
inputs:
script: |
echo Hello world
condition: eq(variables['WhetherToRun'], 'True')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)