我正在尝试将构建配置附加到模板。我们正在运行 TeamCity 10.0.2,使用 PowerShell 4.0 与之交互。
根据TeamCity 10 API 文档,可以将构建附加到模板操作:
从/到模板读取、分离和附加构建配置:GET/DELETE/PUT http://teamcity:8111/app/rest/buildTypes/ /template(PUT 接受带有“text/plain” Content-Type 的模板定位器)
所以我试图将build12
构建配置附加到template12
模板中,我正在使用的代码如下
$webclient = New-Object System.Net.WebClient
$creds = New-Object System.Net.NetworkCredential("user1","pass1")
$webclient.Credentials = $creds
$webclient.headers.Add("Content-Type", "text/plain")
$webclient.UploadString("http://teamcity:8111/httpAuth/app/rest/buildTypes/build12/template", "PUT", "TemplateId")
但我不断收到以下错误:
Exception calling "UploadString" with "3" argument(s): "The remote server returned an error: (400) Bad Request."
有没有人能够通过 API 将构建配置附加到模板?