gpt4 book ai didi

templates - 需要对 Azure Pipeline 模板 yaml 中的每个循环使用 For 循环而不是

转载 作者:行者123 更新时间:2023-12-04 13:35:26 24 4
gpt4 key购买 nike

我知道如何使用每个循环并做了 POC 并且它工作正常。但是我有一个请求,我需要使用 For 循环而不是 For each。

商业案例:需要根据用户输入动态创建任务。
原因 : 一些团队在他们的项目中使用多个 maven 任务。我有一个集中的模板,它将根据用户输入创建任务。他们需要在他们的管道中使用 maven。

示例
${{for i=1;我<= n;我++}}
-任务:maven@5
pompath: ${pomxmlpath}

当 n = 5 时,它必须在 azure 管道中创建 5 个 maven 任务。

最佳答案

没有这样的For loop Azure YAML 管道中的表达式。并且实际上通过在运行时中指定 n 来循环 Azure devops YAML 中的动态模板参数也是不可用的。

Within a template expression, you have access to the parameters context that contains the values of parameters passed in. Additionally, you have access to the variables context that contains all the variables specified in the YAML file plus the system variables. Importantly, it doesn't have runtime variables such as those stored on the pipeline or given when you start a run. Template expansion happens very early in the run, so those variables aren't available.



https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

关于templates - 需要对 Azure Pipeline 模板 yaml 中的每个循环使用 For 循环而不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62409478/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com