1

我想知道是否可以编写 PowerShell 来创建 Azure DevOps 服务连接端点。

我想通过访问 Azure DevOps 来限制每个人创建服务连接端点的访问,我们需要创建多个服务连接端点,包括 UnitTesting 工具、构建工具、自动化测试工具和 docker 事物的连接端点。

Invoke-RestMethod <uri> -Method get -Header <myheader>我可以通过Azure DevOps Rest API 使用 PowerShell ( ( Invoke-RestMethod)。

这就是我获取现有服务连接端点的方式:

##Invoke-RestMethod $url -Method GET -Headers $headers -ContentType 
'application/json' -Verbose

##I refer below code as Example to code to update existing work item, 
this is working but for service connection endpoint, I'm having no clue:
$workitem = Invoke-RestMethod -Uri $wisUrl -Method Get -ContentType 
"application/json" -Headers $header
Write-Host "Before: $($workitem.fields.'System.Title')"

$body = @" 
[
  {
    "op": "add",
    "path": "/fields/System.Title",
    "value": "$($workitem.fields.'System.Title')+DEMO"
  },
  {
    "op": "add",
    "path": "/fields/System.History",
    "value": "Changing Title"
  }
] 
"@

$workitem = Invoke-RestMethod -Uri $wisUrl -Method Patch -ContentType 
"application/json-patch+json" -Headers $header -Body $body
Write-Host "After: $($workitem.fields.'System.Title')"
4

1 回答 1

0

使用Endpoints - Create Rest API是可能的:

POST https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2

请求正文,例如(对于 Azure 端点):

{
  "data": {
     "SubscriptionId": "21312421-4123-1323-3123-12534543",
     "SubscriptionName: "TestSub"
  },
  "id": "2e344hjds-23ds-242fs-42ds-dsfsdaf34s",
  "name": "TestEndpoint",
  "type": "Azure",
  "authorization": {
    "parameters": {
       "Certificate": "dummyCertificate"
     },
     "scheme": "Certificate"
  },
  "isReady": false
}
于 2019-09-03T07:50:08.657 回答