简体   繁体   English

Azure DevOps 管道触发变量

[英]Azure DevOps pipeline trigger variables

We have this below scenario -我们有以下场景 -

Pipeline 1 triggers pipeline 2 and also send variables $(path1), $(path2), $(path3) ... to pipeline 2.管道 1 触发管道 2 并将变量$(path1), $(path2), $(path3) ... 发送到管道 2。

I'm trying to find a way to do a for-each loop for the variables which are being sent from pipeline1.我正在尝试找到一种方法来为从 pipeline1 发送的变量执行for-each循环。

We are using YAML for the setup.我们使用 YAML 进行设置。

Thanks in advance.提前致谢。

You can use each function您可以使用每个 function

parameters:
steps:
- ${{ each p in parameters.pipeline1vars }}:
  - script: echo ${{ p }}

Currently, we can use the expression " resources.pipeline.<Alias>.<var_name> " to only pass some predefined variables of the resource pipeline to the triggered pipeline (see here ).目前,我们可以使用表达式“ resources.pipeline.<Alias>.<var_name> ”仅将资源管道的一些预定义变量传递给触发管道(参见此处)。

We have no way to directly pass the custom variables from the resource pipeline to the triggered pipeline.我们无法将自定义变量从资源管道直接传递到触发管道。

However, you can reference to the article below to try passing the variables through pipeline artifact.但是,您可以参考下面的文章来尝试通过管道工件传递变量。

You can save all the variables you want to pass into the artifact file.您可以将要传递的所有变量保存到工件文件中。 And in the triggered pipeline, you can try to use a loop to read each variable saved in the file.并且在触发管道中,可以尝试使用循环读取文件中保存的每个变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM