TFS 2018 以编程方式创建代理池 [英] TFS 2018 Create agent pool programatically

查看:34
本文介绍了TFS 2018 以编程方式创建代理池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以以编程方式在 TFS 2018 中创建代理池,最好是通过 PowerShell?我在 REST API 中找不到类似的东西.

Is it possible to create an Agent Pool in TFS 2018 programatically, preferably via PowerShell? I cannot find anything like that in REST API.

推荐答案

我不知道为什么它没有很好的文档,但这对我来说对 VSTS 有用:

I don't know why it's not well-documented, but this just worked for me against VSTS:

$token = 'myPAT'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((":{0}" -f $token)))

$uri = 'https://<url>/_apis/distributedtask/pools?api-version=4.1-preview.1'
$result = Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} `
-Body (ConvertTo-Json @{name = 'foo'; autoProvision = $true})

我刚刚查看了门户网站中使用的 REST API 创建代理池并复制了它;如果 TFS 2018 中的 API 版本与 VSTS 中的 API 版本不同,您可以执行相同的操作以找到要使用的正确版本.

I just looked at the REST API used in the web portal to create an agent pool and copied it; if the API version isn't the same in TFS 2018 as it is in VSTS, you can do the same thing to find the correct version to use.

这篇关于TFS 2018 以编程方式创建代理池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆