【问题标题】:TeamCity API setting configuration parametersTeamCity API 设置配置参数
【发布时间】:2016-08-22 14:13:29
【问题描述】:

我有配置参数 current_build_date(用户定义的参数)我只想通过 API TeamCity 将此参数设置为当前日期。

在文档上我看到了这个:

http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/parameters/<parameter_name>

我知道我的构建配置 ID,但我不明白如何通过这个来制作 buildTypeLocator

我假设结果会是这样的:

 curl -u Login:Password \
      -X PUT \
      -d 'valueOfMyParam' \
      -H 'Content-Type: text/plain' \
      http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/parameters/current_build_date

如果知道 TeamCity API 的人能帮助我解决这个问题,我将不胜感激。

我尝试只是传递我的构建配置 ID 而不是 buildTypeLocator,但我得到了错误:

[17:08:25][Step 3/3] Error has occurred during request processing (Not Found).
[17:08:25][Step 3/3] Error: jetbrains.buildServer.server.rest.errors.NotFoundException: No project found by name or internal/external id 'BuildConfigurationID'.

如果我的问题有任何问题或含糊之处,请添加评论,我会尽力解决。

【问题讨论】:

    标签: teamcity teamcity-9.0 teamcity-8.0


    【解决方案1】:

    如果您在浏览器中浏览 REST API 端点,您将能够看到构建定位器的格式。

    访问http://teamcity:8111/httpAuth/app/rest/buildTypes/,您会看到条目有一个href 属性,其中包含buildLocator(通常是属性:值组合)

    然后您就可以使用该 URL 进行导航/通过 API 进行通信

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      我解决了问题:构建类型定位器是 id:Build configuration ID

      current_build_date=`date +%%Y-%%m-%%d:%%H:%%M:%%S` 
      echo $current_build_date;
      curl -u Login:Password \
                    -X PUT \
                    -d $current_build_date \
                    -H 'Content-Type: text/plain' \
                    https://teamcity.billing.ru/httpAuth/app/rest/buildTypes/id:Build
      
      configuration ID/parameters/current_build_date
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-08
        • 2011-11-21
        相关资源
        最近更新 更多