How to Deploy the jar file through jenkins after build process

9,844 views
Skip to first unread message

sumanth veera

unread,
Oct 4, 2015, 10:35:38 AM10/4/15
to Jenkins Users
Hi All,

 i am trying to Deploy the jar files to remote server from the artifacts created.after the build process can any one tell me how to do this .

Basically i need to deploy the jar to remote server.

Thanks
Sumanth Veera

Victor Martinez

unread,
Oct 4, 2015, 11:03:18 AM10/4/15
to Jenkins Users
Hi,

You can either use the scp plugin

- https://wiki.jenkins-ci.org/display/JENKINS/SCP+plugin

Then define those deploy servers in the global config and use that as part of your jenkins job (build steps)

Or use the promotion steps if you want to explicitly configure when it should be deployed those artifacts, likely based on some secured manual actions or on nightly basis as an example:
- https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin

There is already another plugin called deploy but it is only for ear/war files AFAIK

I hope it helps

Cheers

Maciej Jaros

unread,
Oct 8, 2015, 7:40:59 AM10/8/15
to jenkins...@googlegroups.com
sumanth veera (2015-10-04 16:35):
Hi All,

 i am trying to Deploy the jar files to remote server from the artifacts created.after the build process can any one tell me how to do this .

Basically i need to deploy the jar to remote server.

If you have many servers (or plan to grow) it might be easier to setup certificate authentication through SSH. This allows easier parametrization and making easier to read scripts.

Basic steps are (assuming your Jenkins and remote server is Linux based):
  1. Generate your local key (use a default options to generate password-less authentication):
    ssh-keygen -b 4096
  2. Copy your key to remote server:
    ssh-copy-id username@remote_host
  3. Test login:
    ssh username@remote_host
Note that from now on anyone having the certificate will be able to connect to your remote host. So some extra security measures might be required (e.g. enabling drive encryption).

So to copy a file you just execute shell script:
connectionString=username@remote_host
scp /some/local/file.jar $connectionString:/some/remote/file.jar

You can also run scripts:
scp /some/local/file.sh $connectionString:/some/remote/file.sh
ssh $connectionString /some/remote/file.sh

Or copy whole folder to remote:
scp -r /some/local/dir/ $connectionString:/some/remote/dir

Or you can copy remote folder to your jenkins:
scp -r $connectionString:/some/remote/dir /some/local/dir/

Regards,
Nux.
Reply all
Reply to author
Forward
0 new messages