admin管理员组文章数量:1398771
I have a yml pipeline and I would like to have a dict variable like the 'files' variable below
variables:
- template: ../../ci-cd/ado_variables/vars.yml
- template: ../../ci-cd/ado_variables/${{ parameters.vnet }}_vars.yml
- name: files
value:
aaa: aaa.zip
bbb: bbbb.zip
unfortunately when I use this format Azure devops complains:
/ci-cd/ado_pipelines/run_ingestion.yml (Line: 76, Col: 5): A mapping was not expected
is there a way to achieve what i want? and access this variable later in the pipeline? Many thanks
I have a yml pipeline and I would like to have a dict variable like the 'files' variable below
variables:
- template: ../../ci-cd/ado_variables/vars.yml
- template: ../../ci-cd/ado_variables/${{ parameters.vnet }}_vars.yml
- name: files
value:
aaa: aaa.zip
bbb: bbbb.zip
unfortunately when I use this format Azure devops complains:
/ci-cd/ado_pipelines/run_ingestion.yml (Line: 76, Col: 5): A mapping was not expected
is there a way to achieve what i want? and access this variable later in the pipeline? Many thanks
Share Improve this question asked Mar 13 at 10:57 Alberto BAlberto B 5701 gold badge5 silver badges17 bronze badges 1 |2 Answers
Reset to default 1That is a complex task to suggest something without pipeline sources. However, you may consider using parameters from this example (or use as an array): https://learn.microsoft/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#each-keyword
parameters:
- name: listOfFiles
type: object
default:
- key: 'apple'
name: 'apple.txt'
- lemon: 'lemon'
name: 'lemon.txt'
steps:
- ${{ each file in parameters.listOfFiles }} :
- script: echo ${{ file.key }} ${{ file.name }}
Currently, Azure DevOps doesn't support such variable. As a workaround, you can use parameter. Refer to the example below.
parameters:
- name: filesExample
type: object
default:
aaa: aaa.zip
bbb: bbb.zip
steps:
- script: |
echo 'the value of aaa: ${{parameters.filesExample.aaa}}'
echo 'the value of bbb: ${{parameters.filesExample.bbb}}'
Result:
本文标签: Have a dict type variable in Azure yml pipelinesStack Overflow
版权声明:本文标题:Have a dict type variable in Azure yml pipelines - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744705893a2620841.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Variables
.All variables are strings
, refer this docs learn.microsoft/en-us/azure/devops/pipelines/process/…. You can useParameters
with complex data type or using compressed string and then deserialize it when usingVariables
– wenbo - Finding Job Commented Mar 14 at 3:38