Is there a way to set variables in variable groups

前端 未结 2 369
一向
一向 2020-11-30 12:55

I\'m trying to share version information from different pipelines to later use them to create a release config in a release pipeline. So basically I need to share informatio

相关标签:
2条回答
  • 2020-11-30 13:55

    You can not change a variable in a variable group with the logging command task.setvariable (the logging command can change only for a specific run).

    The only way to update a variables in the variable group is with the Rest API:

    PUT https://dev.azure/com/{organization}/{project}/_apis/distributestask/variablegroups/{groupId}?api-version=5.0-preview.1
    

    Request body:

    {
       "variables": {
           "key1": {
              "value": "value1"
         }
      },
      "type": "Vsts",
      "name": "TestVarialeGroup",   
    }
    

    So you need to add a task that excute the above Rest API, for example, PowerShell:

    You need to allow scripts to access the OAuth token (check the checkbox in the agent job options):

    And give Administrate permissions to the build user (to the variable group):

    0 讨论(0)
  • 2020-11-30 13:58

    Could be done via the Azure devops CLI.

    Create the powershell task:

    echo $env:AZURE_DEVOPS_EXT_PAT | az devops login
    az devops configure -d organization=https://dev.azure.com/<your_organisation>/ project=<your_project>
    
    az pipelines variable-group variable update --id <id_here> --name <name_here> --value <value_here>
    
    

    and also create the variable in the task like so

    0 讨论(0)
提交回复
热议问题