将管道变量从Designer传递到YAML作业模板 [英] Pass pipeline variable from Designer to YAML job template
问题描述
我最初想在我的azure-pipelines.yml
中定义可以在队列时间设置的管道变量,但是目前似乎不支持此操作:可以在队列时间设置的变量只能在队列中定义.设计师.该变量(以逗号分隔)名为nx_versions
,将用于构建矩阵策略.这是一个最小的示例:
I initially wanted to define pipeline variables in my azure-pipelines.yml
that I can optionally set at queue time, but it seems that this is not supported at the moment: variables that can be set at queue time can only be defined in the Designer. This variable (comma-separated) is named nx_versions
and will be used to build a matrix strategy. Here's a minimal example:
# azure-pipelines.yml
jobs:
- template: job-template.yml
parameters:
nx_versions: $(nx_versions)
和
# job-template.yml
parameters:
nx_versions:
- 1
jobs:
- job: build
strategy:
matrix:
${{ each nxver in parameters.nx_versions }}:
NX_${{ nxver }}:
NXVersion: ${{ nxver }}
steps:
- powershell: echo $(NXVersion)
使用nx_versions = 2,3
对构建进行排队(值实际上并不重要)会导致错误:
Queuing the build with nx_versions = 2,3
(value doesn't actually matter) results in an error:
/job-template.yml (Line: 9, Col: 9): Expected a sequence or mapping. Actual value '$(nx_versions)'
这甚至有可能吗?我也尝试使用${{ nx_versions }}
和${{ variables.nx_versions }}
无济于事.
Is this even possible? I also tried using ${{ nx_versions }}
and ${{ variables.nx_versions }}
to no avail.
这可以通过完整的Designer解决方案来实现.
This is possible with a full Designer solution.
推荐答案
我遇到了同样的问题.我认为目前这是不可能的.我认为这正在 https://github.com/Microsoft/azure上进行-pipelines-yaml/pull/129
I am running into the same issue. I don't think this is currently possible. I believe this is being worked on https://github.com/Microsoft/azure-pipelines-yaml/pull/129
这篇关于将管道变量从Designer传递到YAML作业模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!