[英]How to assign a network interface to a newly created VM with ARM Powershell?
[英]Assign branch policies to newly created repository in new project
我目前正在一个项目中自动创建存储库。 到目前为止,我已经成功地创建了存储库,创建了主/开发分支并将必备文件放入各自的分支中。
现在我需要为新创建的回购分配分支策略,请记住,这是在全新项目的全新回购中。 到目前为止,我尝试了以下方法但遇到了问题:
当我尝试发布到为这些策略中的任何一个指定的 URL 时,我看到如下错误消息: Invoke-RestMethod: {"count":1,"value":{"Message":"The requested resource does not support http method 'POST'."}}
Azure DevOps CLI is not supported for Azure DevOps server
我认为这可能是一个版本控制问题,因为 output 告诉我它不受支持。 也许我没有正确实现这一点,但语法在它所要求的方面是直截了当的,所以我认为这不是语法问题。
此方法的 post 方法需要相对较小的有效负载; 只是名称、oldObjectID 和 newObjectID。 然而,我在这里遇到的问题是旧分支在 scope 之外,同时试图在不同的 repo 中创建一个新分支。 即使该分支存在于同一项目的回购中,它仍然找不到旧分支的 ID 并在 output 中返回不成功的错误:unresolvableToCommit
I have attempted calling the Azure DevOps REST API " Configurations - Create " via Postman and PowerShell script to set merge strategy policy for a new branch in a new git repository on Azure DevOps Server 2020, and the REST API can work well as expected.
下面是我在我这边尝试的示例。
$pat = '{PAT}'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $pat)))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64AuthInfo))
$headers.Add("Content-Type", "application/json")
$uri = "https://{instance}/{collection}/{project}/_apis/policy/configurations?api-version=6.0"
$body = '{
"isEnabled": true,
"isBlocking": true,
"type": {
"id": "fa4e907d-c16b-4a4c-9dfa-4916e5d171ab"
},
"settings": {
"allowNoFastForward": true,
"allowSquash": true,
"scope": [
{
"repositoryId": "{repositoryId}",
"refName": "refs/heads/main",
"matchKind": "exact"
}
]
}
}'
Invoke-RestMethod -Uri $uri -Headers $headers -Body $body -Method POST | ConvertTo-Json -Depth 10
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.