我需要在 azure devops 中禁用存储库,在 gui 中我们可以在设置项上执行此操作,但是...
是否有 az-cli 命令可以禁用存储库?
诸如“az repos 设置...”之类的内容
最佳答案
用于更新存储库的 azure cli 是“az repos update ”,但它似乎只更新默认分支(--default-branch)或存储库名称“--name”。
作为替代方案,您可以使用rest api“Repositories - Update ”来更新存储库设置。代码示例:
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 - 使用 az-cli 命令禁用 azure devops 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71946830/