如何使用Azure CLI在Azure devops中获取发布管道的变量列表 [英] How to get the list of variable of release pipelines in Azure devops using Azure CLI

查看:264
本文介绍了如何使用Azure CLI在Azure devops中获取发布管道的变量列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am Using Azure CLI, What I want to get the list of variable used in release pipeline . Current I am able to get the list of variable used in build pipeline using command az pipelines variable List

请让我知道如何通过CLI使用我不想要的控制台,因为很难复制和粘贴在发布管道中使用的所有变量"来获取在发布管道中使用的变量列表.

Please let know how can I get the list of variables used in release pipeline using CLI "through console I don't want as it is difficult to copy and paste all variable used in release pipeline"

推荐答案

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

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

Azure Devops CLI中没有可用的命令来列出发布管道的变量,您必须使用 rest api 可以获取您需要的长响应变量.

There's no command available in Azure Devops CLI to list the variables of release pipeline, you have to use az devops invoke + rest api to get the variables you want in long response.

要获取发布变量,我们可以使用此

To get release variables we can use this rest api, let me convert it into az devops invoke command :

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替换为您身边的值.当我们在Web门户中编辑发布管道时,ReleaseDefinitionID很容易找到:

1.You should replace the MyOrgName, MyProjectName and ReleaseDefinitionID with the values on your side. And the ReleaseDefinitionID is something easy to find when we edit a release pipeline in web portal:

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

2.Since variables in release pipeline can be scoped in one stage or whole pipeline. Assuming I have VarA:Test1 in stage1, VarB:Test2 in stage2, and VarC:Test3 in whole release pipeline. The response would look like this structure:

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

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

变量具有不同的级别,请谨慎使用.希望对您有所帮助.

The variables have their different levels, please be careful with them. Hope it helps.

更新1:

要使用az devops命令,没有此扩展名的人需要使用az extension add --name azure-devops之类的方式添加devops扩展名.

To use az devops command, someone who doesn't have this extension needs to add the devops extension using something like az extension add --name azure-devops.

这篇关于如何使用Azure CLI在Azure devops中获取发布管道的变量列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆