[英]Change variable group value of Azure Pipeline
I have a Variable Group in Azure Pipeline(below attached),我在 Azure Pipeline 中有一个变量组(附件如下),
I want to change the value of isPOS to False through below mentioned conditions,我想通过下面提到的条件将 isPOS 的值更改为 False,
$angular = (Get-Content "$(system.defaultworkingdirectory)/amaze-commerce/angular.json" -Raw) | ConvertFrom-Json
if ($angular.defaultProject -ne "ecomm-ac-ecomm"){
// Please add your code here
}
Can you please guide me to change the Variable group value and i want to use the same in Release Pipeline.你能指导我更改变量组值吗,我想在发布管道中使用相同的值。
In order to change the value of a variable group use Azure DevOps Api .要更改变量组的值,请使用Azure DevOps Api 。
An example of how to update a variable group:如何更新变量组的示例:
Variablegroups - Get Variable Groups - filtered by {groupName}变量组 - 获取变量组 - 按 {groupName} 过滤
$pat ="<your-tfs-security-token>"
$read = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$pat"))
$variableGroupName = "Check for angular.json"
$variableGroupId = ((Invoke-RestMethod -Method Get -Headers @{'Authorization' = "Basic $read" } -Uri "https://{instance}/{collection}/{project}/_apis/distributedtask/variablegroups?groupName=${variableGroupName}").Value).id
Variablegroups - Update变量组 - 更新
$body =@"
{
"variables": {
"isPOS": {
"value": $false
}
},
"type": "Vsts",
"name": "${variableGroupName}",
"description": "Updated variable group"
}
"@
$response= (Invoke-RestMethod -Uri "https://{instance}/{collection}/{project}/_apis/distributedtask/variablegroups/${variableGroupId}?api-version=5.0-preview.1" -Method Put -Headers @{'Authorization' = "Basic $read" } -ContentType "application/json" -Body $body)
I have a Variable Group in Azure Pipeline(below attached),我在Azure Pipeline中有一个变量组(如下所示),
I want to change the value of isPOS to False through below mentioned conditions,我想通过以下条件将isPOS的值更改为False,
$angular = (Get-Content "$(system.defaultworkingdirectory)/amaze-commerce/angular.json" -Raw) | ConvertFrom-Json
if ($angular.defaultProject -ne "ecomm-ac-ecomm"){
// Please add your code here
}
Can you please guide me to change the Variable group value and i want to use the same in Release Pipeline.您能否指导我更改“变量”组值,我想在“发布管道”中使用相同的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.