TeamCity API 设置配置参数

TeamCity API setting configuration parameters

我有配置参数 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'.

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

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

访问 http://teamcity:8111/httpAuth/app/rest/buildTypes/,您会看到条目具有包含 buildLocator 的 href 属性(通常是 property:value 组合)

然后您将能够使用 url 导航/通过 API

进行通信

希望对您有所帮助

我解决了问题:构建类型定位器是 id:构建配置 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