az devops powershell传递空间分隔值

问题描述

AZ devops命令 az pipelines variable-group create将-变量定义为“格式为键=值空间分隔对的变量”

我需要创建一个包含20个以上的key = value对的变量组。我发现很难作为变量来做到这一点。

此命令行有效

 az pipelines variable-group create --name myname --variables “owner=Firstname Lastname” “application=cool-name” 

我正在尝试做这样的事情:

$tags ={owner='Firstname Lastname' application='cool-name'} 
az pipelines variable-group create --name owgroup --variables $tags 

我看了看这篇有希望的文章,但建议的答案不起作用 Space separated values; how to provide a value containing a space

有什么想法可以实现吗?

解决方法

您可以尝试以下操作。

$tags=(“owner=Firstname Lastname”,“application=cool-name”)
az pipelines variable-group create --name owgroup --variables $tags

我没有AZ DevOps,但是在PowerShell ISE上使用Azure CLI验证了类似的情况。如果您在Bash上运行Az CLI,则可以遵循linked answer

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...