2016-08-22 162 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