Azure Pipeline每期

发布于 2025-01-25 10:52:20 字数 576 浏览 4 评论 0原文

我发现了许多有关在Azure管道中使用每个循环的示例,但是我发现所有循环都使用参数作为数组。 使用代码中创建的数组怎么样? 我是说:

  - script: COMMAND=$(npx nx affected:apps --base=$(BASE_SHA) --head=$(HEAD_SHA) --plain) && echo "##vso[task.setvariable variable=APPLICATIONS;]$COMMAND"

  - task: Bash@3
    inputs:
      targetType: 'inline'
      script: |
          echo 'APPLICATIONS + $(APPLICATIONS)'
          readarray -d ' ' -t ARRAYAPPS <<<'$(APPLICATIONS)'
          echo ${ARRAYAPPS[0]}
          echo ${ARRAYAPPS[1]}
  
  - ${{each APPLICATION in $APPLICATIONS }}:
  - task: ...

I found a lot of examples about using EACH loop in an Azure pipeline, but all of them I found are using a parameter as the array.
What about using an array that was created in the code?
I mean:

  - script: COMMAND=$(npx nx affected:apps --base=$(BASE_SHA) --head=$(HEAD_SHA) --plain) && echo "##vso[task.setvariable variable=APPLICATIONS;]$COMMAND"

  - task: Bash@3
    inputs:
      targetType: 'inline'
      script: |
          echo 'APPLICATIONS + $(APPLICATIONS)'
          readarray -d ' ' -t ARRAYAPPS <<<'$(APPLICATIONS)'
          echo ${ARRAYAPPS[0]}
          echo ${ARRAYAPPS[1]}
  
  - ${{each APPLICATION in $APPLICATIONS }}:
  - task: ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不会写诗 2025-02-01 10:52:20

管道$ {{每个不支持运行时管道变量。它仅支持参数,因为在编译时评估了每个每个。当时,只有参数(以及基于它们的变量)可用。

Pipeline ${{each does not support runtime pipeline variables. It only supports parameters, because the each is evaluated at compile time; and at that time, it is only parameters (and variables based on them) that are available.

べ繥欢鉨o。 2025-02-01 10:52:20

“如果您以某种方式被阻止,请尝试以这种方式改变”
我修改了该方法,然后在Bash脚本中包括了循环:

readarray -d ' ' -t ARRAYAPPS <<<$(APPLICATIONS)
if (( ${#APPLICATIONS[@]} > 0 )); then
  for (( i=0; i<${#APPLICATIONS[@]}; i++ ));
    ...

"If you're blocked in a way, try to change this way"
I modified the approach, and I included the loop inside the bash script:

readarray -d ' ' -t ARRAYAPPS <<<$(APPLICATIONS)
if (( ${#APPLICATIONS[@]} > 0 )); then
  for (( i=0; i<${#APPLICATIONS[@]}; i++ ));
    ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文