Posted by: xask | May 14, 2010

Ant SCP task through http_proxy

I was trying to remote copy a war file for deployment to a server,
which can be done using
1.  <scp verbose=”true” file=”remote_deployment/file.war” todir=”user:pass@~/jetty/webapps”/>
2.  We just need to add a jar to the ANT classpath for this to work  available here http://www.jcraft.com/jsch/

the problem I faced was that I was behind a proxy, and there is currently no way of specifiying a proxy for Jsch from a build file. (here is <setproxy /> task but it does not work with Jsch.
The solution : JSch library is a implementation of SSH in pure java, so we modify it to do that
I patched the src/com/jcraft/jsch/JSch.java file to get the environment variable (http_proxy) and use it for initiating a connection through the proxy to the host.
Here is the patched jar file
download it from here
Another point : on most systems http_proxy won’t be available on non login shells.
hence we need to set the environment variable in eclipse,
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: