【问题标题】:Teamcity REST API get latest successful build on a branchTeamcity REST API 在分支上获得最新的成功构建
【发布时间】:2013-09-09 19:58:18
【问题描述】:

我使用 git flow 和 teamcity 作为我的 CI 服务器。我想从特定分支的最新成功构建中提取工件。

我可以使用此网址获取分支上的最新版本:http://$teamcity$/httpAuth/app/rest/buildTypes/name:$BuildTypeName$/builds/branch:name:$branchName$

但如果分支名称包含 /(例如,git 流名称分支 feature/%release/%),则会失败。

我尝试过对/ 进行编码的url。例如,如果$branchName$> == 'release/branchName' 我使用/builds/branch:name:release%2F$branchName$)

  • 作品-/builds/branch:name:develop
  • 失败 - /builds/branch:name:release%2F$branchName$.

我没有收到 API 错误,但 api 结果为空。

【问题讨论】:

    标签: git rest teamcity


    【解决方案1】:

    显然这是 bug in TeamCity 从 8.0.3 开始

    看起来正在处理中。

    【讨论】:

    • 从 9.0.1 开始仍然存在问题。
    【解决方案2】:

    您可以通过将构建定位器放入查询字符串而不是作为 URL 的路径元素的一部分来解决此问题,即您可以使用 /builds?locator=branch:name:release%2F1.0.1 代替 /builds/branch:name:release%2F1.0.1 等。返回的数据格式似乎不一样,但它确实包含内部构建 ID,因此您始终可以使用该 ID 再次请求该确切构建,例如/builds/id:3332.

    另一个我没有亲自尝试过的点是在 JetBrains 的问题跟踪器的 this comment 上找到的:

    我对此进行了深入研究,发现 Tomcat 版本 6.0.10 和更高版本默认不再接受路径元素中的编码斜杠和反斜杠。可以通过更改两个 Tomcat 服务器属性(在 http://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10 上找到)来更改此行为:

    -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
    -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true
    

    我不知道这是否被认为是一种糟糕的安全做法。

    【讨论】:

      【解决方案3】:

      如果没有 Keith 建议的修复,以下操作将失败:

      http://$teamcity$/httpAuth/app/rest/buildTypes/name:$BuildTypeName$/builds/branch:name:$urlEncodedBranchName$
      

      但由于 Tomcat 确实允许在查询参数中使用转义斜杠,因此以下内容将起作用:

      http://$teamcity$/httpAuth/app/rest/buildTypes/name:$BuildTypeName$/builds?branch:name:$urlEncodedBranchName$
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-24
        • 1970-01-01
        • 1970-01-01
        • 2012-06-20
        相关资源
        最近更新 更多