azure - 使用 az-cli 命令禁用 azure devops 存储库

标签 azure azure-devops

我需要在 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)}

enter image description here

关于azure - 使用 az-cli 命令禁用 azure devops 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71946830/

相关文章:

Microsoft 托管代理和并行作业上的 Azure 计费

azure - 阻止 Azure Function 向 Application Insights 进行过多日志记录

azure - Azure 存储 CDN 和 CORS 问题

适用于现有 Azure 基础设施的 Azure 登陆区

azure - 重新输入您的凭据 - 无法连接到 Azure

wcf - Team Foundation 服务的 SOAP 警报

azure - 使用 Azure SQL 的 ASP.Net Core 2.1 Serilog SQL Server 接收器在本地运行,但不能从 Azure 应用服务运行

git - 如何解决 VSTS 中 pull 请求中的 merge 冲突?

azure - 使用 REST API 运行 Azure DevOps 测试用例

Azure DevOps,如何在 DevOps 待办事项中添加 "Work Item type"