gpt4 book ai didi

azure-devops - 如何使用 Azure CLI 在 Azure devops 中获取发布管道的变量列表

转载 作者:行者123 更新时间:2023-12-05 00:56:58 27 4
gpt4 key购买 nike

我正在使用 Azure CLI,我想获取发布管道中使用的变量列表。当前我能够使用命令获取构建管道中使用的变量列表az 管道变量列表

请告诉我如何使用 CLI“通过我不想要的控制台获取发布管道中使用的变量列表,因为很难复制和粘贴发布管道中使用的所有变量”

最佳答案

How to get the list of variable of release pipelines in Azure devops using Azure CLI

Azure Devops CLI 中没有可用的命令来列出发布管道的变量,您必须使用 az devops invoke + rest api在长响应中获取您想要的变量。

要获取发布变量,我们可以使用 rest api ,让我把它转换成 az devops invoke 命令:

az devops invoke --org https://dev.azure.com/MyOrgName/ --area release --resource definitions --http-method Get --route-parameters project=MyProjectName definitionId=ReleaseDefinitionID --api-version 5.1 -o json

更多详情:

1.您应该将 MyOrgName、MyProjectName 和 ReleaseDefinitionID 替换为您身边的值。而 ReleaseDefinitionID 在我们在门户网站中编辑发布管道时很容易找到:

enter image description here

2.由于发布管道中的变量可以在一个阶段或整个管道中进行作用域。假设我在 stage1 中有 VarA:Test1,在 stage2 中有 VarB:Test2,在整个发布管道中有 VarC:Test3。响应看起来像这样的结构:

"variables": {
"VarC": {
"value": "Test3"
}
},
"variableGroups": [],
"environments": [
{
"id": 1,
"name": "Stage 1",
...
"variables": {"VarA" xxx},

"id": 2,
"name": "Stage 2",
...
"variables": {"VarB" xxx}...

变量有不同的级别,请小心。希望对您有所帮助。

更新1:

要使用 az devops 命令,没有此扩展的人需要使用 az extension add --name azure-devops 之类的东西添加 devops 扩展。

关于azure-devops - 如何使用 Azure CLI 在 Azure devops 中获取发布管道的变量列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61325671/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com