【问题标题】:PUT update a TeamCity Configuration Parameter working from PostMan but not from Powershell ScriptPUT 更新从 PostMan 工作但不是从 Powershell 脚本工作的 TeamCity 配置参数
【发布时间】:2017-12-09 04:23:18
【问题描述】:
$url = "https://teamcity.myserver.io/guestAuth/app/rest/buildTypes/id:SandboxPlayGround_WindowsForms1_Build/parameters/Version" 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Content-Type", 'text/plain')

$headers.Add("Origin", 'https://teamcity.myserver.io')

Invoke-RestMethod -Method Put -Uri $url -Headers $headers -Body "2.3.1.0"

给我错误:

[19:54:59][Step 2/6] Invoke-RestMethod : HTTP Status 405 - Request method 'PUT' not supported
[19:54:59][Step 2/6]
[19:54:59][Step 2/6]
[19:54:59][Step 2/6]
[19:54:59][Step 2/6] type Status report
[19:54:59][Step 2/6] message Request method 'PUT' not supported
[19:54:59][Step 2/6] description The specified HTTP method is not allowed for the requested resource.

但是我可以使用来自 PostMan 的相同 URL 和标头来更新参数值。 我哪里错了?

【问题讨论】:

    标签: powershell continuous-integration teamcity continuous-deployment fluenttc


    【解决方案1】:

    您可以使用 C# 使用 FluentTc 库设置构建配置参数:

    new RemoteTc()
      .Connect(_ => _.ToHost("teamcity.myserver.io")
        .AsUser("MYUSERNAME", "MYPASSWORD"))
      .SetBuildConfigurationParameters(
        _ => _.Id("SandboxPlayGround_WindowsForms1_Build"),
        _ => _.Parameter("Version", "2.3.1.0") );
    

    如果需要,您可以使用以下技术之一从 Powershell 调用此代码: http://executeautomation.com/blog/calling-c-code-in-powershell-and-vice-versa/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-12
      相关资源
      最近更新 更多