使用 az-cli 命令禁用 azure devops 存储库
Disable azure devops repos with az-cli comand
我需要在 azure devops 中禁用存储库,在 gui 中我们可以在设置项上进行,但是...
是否有禁用存储库的 az-cli 命令?
类似于“az repos settings ...”
用于更新 repostiroy 的 azure cli 是“az repos update”,但它似乎只更新默认分支(--default-branch)或存储库名称“--name”。
作为替代方案,您可以使用 rest api "Repositories - Update" 来更新 repo 设置。代码示例:
Param(
[string]$org = "orgname",
[string]$project = "projectname",
[string]$repositoryId = "repositoryid",
[string]$token = "PAT"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$json = '{ "isDisabled" : "true" }'
$uri = "https://dev.azure.com/$org/$project/_apis/git/repositories/$repositoryId" + "?api-version=6.0"
Write-Host $uri
$result = Invoke-RestMethod -Uri $uri -Method Patch -Body $json -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
我需要在 azure devops 中禁用存储库,在 gui 中我们可以在设置项上进行,但是...
是否有禁用存储库的 az-cli 命令?
类似于“az repos settings ...”
用于更新 repostiroy 的 azure cli 是“az repos update”,但它似乎只更新默认分支(--default-branch)或存储库名称“--name”。
作为替代方案,您可以使用 rest api "Repositories - Update" 来更新 repo 设置。代码示例:
Param(
[string]$org = "orgname",
[string]$project = "projectname",
[string]$repositoryId = "repositoryid",
[string]$token = "PAT"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$json = '{ "isDisabled" : "true" }'
$uri = "https://dev.azure.com/$org/$project/_apis/git/repositories/$repositoryId" + "?api-version=6.0"
Write-Host $uri
$result = Invoke-RestMethod -Uri $uri -Method Patch -Body $json -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}