如何使用 Rest API link 变量组到 azure 管道?

How to link variable group to azure pipeline using Rest API?

是否可以使用 Rest API 将变量组添加到 Azure 管道?

是的,有一个RestAPI添加一个变量组,Variablegroups - Add:

POST https://dev.azure.com/{organization}/{project}/_apis/distributedtask/variablegroups?api-version=5.1-preview.1

例如:

POST https://dev.azure.com/fabrikam/DGDemo/_apis/distributedtask/variablegroups?api-version=5.1-preview.1

正文:

{
  "variables": {
    "key1": {
      "value": "value1"
    },
    "key2": {
      "value": "value2",
      "isSecret": true
    }
  },
  "type": "Vsts",
  "name": "TestVariableGroup1",
  "description": "A test variable group"
}