4

curl is not recognized as an internal or external command while running the Teamcity command line script. Curl is installed in local and works fine in command prompt.

Build log Result :

[20:05:35]Step 2/2: Command Line
[20:05:35][Step 2/2] Starting: C:\BuildAgent\temp\agentTmp\custom_script7047202395618427524.cmd
[20:05:35][Step 2/2] in directory: C:\BuildAgent\work\376652cbd18bb804
[20:05:35][Step 2/2] 'curl' is not recognized as an internal or external command,
[20:05:35][Step 2/2] operable program or batch file.
[20:05:35][Step 2/2] Process exited with code 1
[20:05:35][Step 2/2] Step Command Line failed

curl command

curl -v --request PUT %teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%/pin 
-u    admin:admin
karthik
  • 105
  • 2
  • 15
  • This might be helpful: http://stackoverflow.com/questions/8611192/curl-command-failure – anovitskiy Nov 19 '13 at 18:04
  • Given below is the command should use to get the build information. curl -v --basic --request GET %teamcity.serverUrl%/httpAuth/app/rest/changes? build=id:%teamcity.build.id% --data true --header "Content-Type: text/xml" – karthik Nov 19 '13 at 18:47

3 Answers3

4

Expanding on the other answers, you do need to tell TeamCity where curl is.

But, you can do this through TeamCity by appending the path to curl to your env.Path variable, and the nice thing about this is you do not have to change the PATH variable on every build agent.

  1. In your build configuration, add env.Path under the "Build Parameters" section.
  2. For the value, you need to specify the path to curl plus keep the existing values; something like:

    c:\path\to\dirWithCurl;%env.Path%

  3. Add a test build step if you like to prove that it worked; simply do the following and view the results:

    echo %env.Path%
    curl --help

I explored how TeamCity handles appending values to this recently... see this answer for way too much information and an example with MySql. Look at edit #2, but the basics you need are above.

Community
  • 1
  • 1
Damon
  • 1,249
  • 1
  • 15
  • 27
0

You'll need to:

a) Do as anovitskiy suggested and add it to the path. But then restart the build agent to have it pick it up the new path.

or

b) Instead of saying curl do C:\Path\To\Location\of\curl.exe as the command.

Welsh
  • 5,138
  • 3
  • 29
  • 43
0

Had same issue. And found out this. Since Win 10 1803 Curl is part of system and located at %windir%\System32 But TeamCity Agent on Win64 can't found any executable at this folder Thanx to this answer, it appears as Windows problem (More detais here)

So I modified my script to run both locally and as a build step:

IF EXIST %windir%\Sysnative\curl.exe (
%windir%\Sysnative\curl.exe -X GET "http://example.com"
) ELSE (
curl -X GET "http://example.com"
)
ad1Dima
  • 3,185
  • 2
  • 26
  • 37