我是否应该能够使用Azure DevOps CLI扩展访问发布管道变量

时间:2020-09-10 21:59:32

标签: azure-devops azure-cli

我安装了Azure DevOps CLI扩展程序的预览版,并验证了其安装。我使用az devops configure --defaults organization=https://dev.azure.com/XXX project="XXX"设置了一些默认值。我可以使用az pipelines release create --definition-name "XXX"触发发布。基于此,看来我的安装很好,并且我应该能够执行我尝试的操作。顺便说一句,我正在为此使用Azure门户中的Cloud Shell,但最终会将我的工作移至经典版本管道中的Azure CLI任务。

当我运行以下命令时:

az pipelines variable update --org https://dev.azure.com/XXX --project "XXX" --pipeline-name  "XXX" --name "var_name" --value "var_value"

我收到以下消息:

There were no build definitions matching name "XXX" in project "XXX".

运行以下命令时,我会收到相同的消息:

az pipelines variable list --org https://dev.azure.com/XXX--project "XXX" --pipeline-name  "XXX"

一个问题,该消息引用了内部版本定义。我没有指定构建定义。这是一个经典的(YAML之前的版本)定义,并且确实存在。

我是否可以使用此扩展名访问和操纵发布管道变量?扩展程序的“文档”页面未引用构建或发行版定义。

1 个答案:

答案 0 :(得分:0)

Thi CLI选项适用于管道,不适用于发行版。您可以选择两种可能的工作方法之一。

  1. 使用常规命令
az devops invoke --org https://dev.azure.com/thecodemanual/ --area release --resource definitions --http-method Put --route-parameters project="DevOps Manual" definitionId=7 --in-file 9.json --api-version 5.1  

9.json中,我具有通过此端点获得的发布定义

https://vsrm.dev.azure.com/{{organization}}/{{project}}/_apis/release/definitions/7?api-version=6.1-preview.4

具有修改后的变量部分:

    "variables": {
        "ReleaseVersion": {
            "value": "Version-from-cli"
        }
    },

enter image description here

请注意,阶段范围变量会出现在阶段定义范围中。

  1. 使用变量组并在其中定义变量,然后使用CLI from variables groups
az pipelines variable-group variable update --group-id
                                            --name
                                            [--detect {false, true}]
                                            [--new-name]
                                            [--org]
                                            [--project]
                                            [--prompt-value {false, true}]
                                            [--secret {false, true}]
                                            [--value]
相关问题