Using Curl in a Go Job

751 views
Skip to first unread message

Ashwin Mathews

unread,
Mar 17, 2014, 9:11:42 AM3/17/14
to go...@googlegroups.com
Hi,

I am trying to setup my pipeline to build my code and deploy it to a linux shared server. For this, I am trying to leverage Curl which would allow me to FTP over SSL. I have set CURL as an evironmental varriable at the Pipeline level but still it is not able to find the 'curl' command
Help!

Below is the error I am getting..

[go] setting environment variable 'CURL' to value 'C:\Program Files\cURL\bin'
'curl' is not recognized as an internal or external command,
operable program or batch file.

The command:

curl -T "d:\test.txt" ftp://user:password@url -k --ftp-ssl

Rustin Daniels

unread,
Mar 17, 2014, 11:14:37 AM3/17/14
to go...@googlegroups.com
Hi,

There could be a couple of causes for the error.

First access environment variables, would you not need to use %CURL% ... ?
Second. The path C:\Program Files\cURL\bin\curl.exe could also cause issues specifically the space between Program and Files give '"C:\Program Files\cURL\bin"' a shot

Hope that helps.

Rustin

Ashwin Mathews

unread,
Mar 17, 2014, 11:22:08 AM3/17/14
to go...@googlegroups.com
That doesn't seem to be working either, see below,

[go] overriding environment variable 'JAVA_HOME' with value 'C:\Program Files\Java\jdk1.7.0_51'
[go] setting environment variable 'CURL' to value '"C:\Program Files\cURL\bin"'
'curl' is not recognized as an internal or external command,
operable program or batch file.

The thing is, I am setting JAVA_HOME again and it says it is overriding my environment variable. That seems to be fine with the space though.

Ken Mugrage

unread,
Mar 17, 2014, 11:25:58 AM3/17/14
to Ashwin Mathews, go...@googlegroups.com

I don't think making curl an environment variable will add it to your executable path where Go (or any other program) would find it. If curl is a command you'd like to be able to use from anywhere on that machine I'd add it to the machine path outside of Go. 

Ken


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ken Mugrage - ThoughtWorks Studios
kmug...@thoughtworks.comhttp://www.thoughtworks.com | Twitter: @kmugrage
Go, the Continuous Delivery platform is moving to open source! http://www.go.cd/

Ashwin Mathews

unread,
Mar 17, 2014, 12:26:28 PM3/17/14
to go...@googlegroups.com, Ashwin Mathews
Ken,

I was part of your demo on CD last Thursday and got all my attention into Go..Thanks for that! :)

The curl command does work when I run the command on cmd (outside of Go) as I have already set it as my system variable. The only problem comes when I run the command in Go.

Ken Mugrage

unread,
Mar 17, 2014, 12:31:04 PM3/17/14
to Ashwin Mathews, go...@googlegroups.com
On Mon, Mar 17, 2014 at 9:26 AM, Ashwin Mathews <achu...@gmail.com> wrote:
Ken,

I was part of your demo on CD last Thursday and got all my attention into Go..Thanks for that! :)

Very glad it was useful :)
 

The curl command does work when I run the command on cmd (outside of Go) as I have already set it as my system variable. The only problem comes when I run the command in Go.


A couple things to try..

- Make sure it's the system path you updated and not your personal path
- If you added it after the Go agent was started you may need stop stop and start the agent to pick up the new path.

Hope that helps! 

Ken

Sriram Narayanan

unread,
Mar 17, 2014, 12:58:46 PM3/17/14
to Ken Mugrage, Ashwin Mathews, go...@googlegroups.com
I set a pipeline level environment variable called CURL to the value of the full path to the curl.exe file (including the file name itself) in double quotes, and then ran the command %CURL%.
[go] Start to execute task: <exec command="%CURL%" >
<arg>--help</arg>
</exec>. 
[go] setting environment variable 'GO_SERVER_URL' to value 'https://127.0.0.1:8154/go/'
[go] setting environment variable 'GO_TRIGGER_USER' to value 'anonymous'
[go] setting environment variable 'GO_PIPELINE_NAME' to value 'Trial'
[go] setting environment variable 'GO_PIPELINE_COUNTER' to value '2'
[go] setting environment variable 'GO_PIPELINE_LABEL' to value '2'
[go] setting environment variable 'GO_STAGE_NAME' to value 'defaultStage'
[go] setting environment variable 'GO_STAGE_COUNTER' to value '1'
[go] setting environment variable 'GO_JOB_NAME' to value 'defaultJob'
[go] setting environment variable 'GO_REVISION' to value 'd0b585f0c13b1289fe749d9f7c8f0776f4bead11'
[go] setting environment variable 'GO_TO_REVISION' to value 'd0b585f0c13b1289fe749d9f7c8f0776f4bead11'
[go] setting environment variable 'GO_FROM_REVISION' to value 'd0b585f0c13b1289fe749d9f7c8f0776f4bead11'
[go] setting environment variable 'CURL' to value '"D:\Some Tools\curl\bin\curl.exe"'
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
     --anyauth       Pick "any" authentication method (H)

In case you want to set CURL to be the PATH to curl, then here's what you would have:
an environment variable called CURL pointing to (in my case) : "D:\Some Tools\curl\bin\"

and then use the above as
%CURL%\curl.exe --help

-- Ram



--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
------------------------------------
Belenix: www.belenix.org
Twitter: @sriramnrn

Ashwin Mathews

unread,
Mar 17, 2014, 1:04:20 PM3/17/14
to go...@googlegroups.com, Ken Mugrage, Ashwin Mathews
Thanks Sriram for your time! Giving it a shot..

Ashwin Mathews

unread,
Mar 17, 2014, 1:16:20 PM3/17/14
to go...@googlegroups.com, Ken Mugrage, Ashwin Mathews
Thanks Sriram!! That's a good workaround..seems to be working as expected..
Thanks guys for your time! Really appreciate the support..

Sriram Narayanan

unread,
Mar 17, 2014, 1:18:25 PM3/17/14
to Ashwin Mathews, go...@googlegroups.com, Ken Mugrage
Glad to be of help.

What did you finally choose to do ? Set CURL to point to curl.exe, or use %CURL%\curl.exe?

-- Ram


On Mon, Mar 17, 2014 at 10:46 PM, Ashwin Mathews <achu...@gmail.com> wrote:
Thanks Sriram!! That's a good workaround..seems to be working as expected..
Thanks guys for your time! Really appreciate the support..

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashwin Mathews

unread,
Mar 17, 2014, 1:26:48 PM3/17/14
to go...@googlegroups.com, Ashwin Mathews, Ken Mugrage
I set my Pipeline env variable as below,

CURL -> "C:\Program Files\cURL\bin"

and my Job command says,

%CURL%\curl.exe -T "d:\test.txt" ftp://user:password@url -k --ftp-ssl
Reply all
Reply to author
Forward
0 new messages