2016-08-22 163 views
0

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

在文档我已经看到了这一点:

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将帮助我解决这个问题。

我做的尝试只是为了代替通过buildTypeLocator我的构建配置ID,我得到了错误:

[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'. 

如果有任何问题或含糊不清我的问题,请添加评论,我会尝试修复它。

回答

3

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

访问http://teamcity:8111/httpAuth/app/rest/buildTypes/,你会看到的条目有一个包含buildLocator href属性(一般属性:值组合)

enter image description here

然后您就可以使用该网址导航/通过API沟通

enter image description here

希望这有助于

+0

感谢您的帮助。 –

0

我解决的问题:构建类型定位为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