2016-09-16 47 views
0

當前構建狀態作爲構建步驟,我嘗試使用下面的命令行代碼來檢索當前構建的構建狀態:使用cURL檢索的TeamCity

curl –u "%system.teamcity.auth.userId%:%system.teamcity.auth.password%" \ 
     "%teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%/status" 

當我在本地執行此操作,它工作並返回狀態,例如。 FAILURE

然而,當我在TeamCity的代理運行它,我得到以下回饋:

[15:11:21][Step 9/10] % Total % Received % Xferd Average Speed Time Time  Time Current 
[15:11:21][Step 9/10]         Dload Upload Total Spent Left Speed 
[15:11:21][Step 9/10] 0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0curl: (6) Could not resolve host: –u 
[15:11:21][Step 9/10] curl: (6) Could not resolve host: TeamCityBuildId=15124 
[15:11:21][Step 9/10] 100 82 0 82 0  0 1536  0 --:--:-- --:--:-- --:--:-- 1536 
[15:11:21][Step 9/10] "Authorization" header is not specified 
[15:11:21][Step 9/10] To login manually go to "/login.html" page 
[15:11:21][Step 9/10] Process exited with code 0 

像它的下落,因爲驗證過這似乎給我。但爲什麼會發生?我已經指定了訪問憑證,爲什麼它沒有正確使用它們?

回答

1

curl: (6) Could not resolve host: TeamCityBuildId=15124表示某個參數不匹配,因爲您的服務器未命名爲TeamCityBuildId=15124

運行curl.exe -u "user:password" "http://thisdomaindoesnotexist/httpAuth/app/rest/b uilds/id:1234/status"給我curl: (6) Couldn't resolve host 'thisdomaindoesnotexist'

你curl命令(使用正確的參數)在TeamCity的工作對我來說:

[21:11:57]Step 1/1: Test (Command Line) 
[21:11:57][Step 1/1] Starting: C:\curl-7.45.0\bin\curl.exe -u username:password http://secret.cloudapp.net/httpAuth/app/rest/builds/id:1234/status 
[21:11:57][Step 1/1] in directory: C:\TeamCity\buildAgent\work\316bb6a03438b498 
[21:11:57][Step 1/1] % Total % Received % Xferd Average Speed Time Time  Time Current 
[21:11:57][Step 1/1]         Dload Upload Total Spent Left Speed 
[21:11:57][Step 1/1] 0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0 
[21:11:57][Step 1/1] 0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0 
[21:11:57][Step 1/1] 100  7 0  7 0  0  64  0 --:--:-- --:--:-- --:--:-- 64 
[21:11:57][Step 1/1] SUCCESS 
[21:11:57][Step 1/1] Process exited with code 0 
+0

看來我必須在某處犯了一個錯字,因爲經過很多迭代後,返回到原來的'curl -u「%system.teamcity.auth.userId%:%system.teamcity.auth.password%」 「%teamcity.serverUrl%/ httpAuth/app/rest/builds/id:%teamcity.build.id%/ status」'請求現在對我來說也正常工作! –

0

它的工作這個關鍵:

--user login:password

代替:

-u

對於curl 7.45Windows 10對我而言。