Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins : how to check out artifact from Nexus and Deploy on Tomcat-

Tags:

I am tying to set up a Jenkins Pipeline. The first stage is done, the code compiles, is tested, inspected and deployed to Nexus.

I would like now to make a second stage on the pipeline where the war is checked out from Nexus and deployed on tomcat.

Actually I already integrated the maven-tomcat plugin to deploy on Tomcat. My question is how can I check out the latest build of the war ?

Is there any maven or jenkins plugin for that ?

Many thanks,

Patrick

like image 560
user1003331 Avatar asked Aug 07 '12 14:08

user1003331


2 Answers

Your binary repository manager (Nexus) should ideally occupy the following position in you overall architecture:

enter image description here

You can use Jenkins as your provisioning tool, but ideally it should launch some sort of process which pulls the artifact to be deployed directly from Nexus (If nothing else it's more efficient).

This is a lot easier than it sounds. For example the Nexus REST API could be called from a shell script to download any desired revision of an artifact. For example:

$CATALINA_HOME/bin/shutdown.sh
curl -o $CATALINA_HOME/webapps/myfile.war http://myrepo.com/service/local/artifact/maven/redirect?r=releases&g=com.myorg&a=myfile&v=1.1.1&e=war
$CATALINA_HOME/bin/startup.sh

Finally, perhaps you might wish to consider a dedicated system for managing your deployments? An interesting solution I've been playing with is rundeck, which has a plugin for Jenkins. I really like rundeck, due to it's simplicity a trait it shares with Jenkins. There is also a plugin for Nexus that enables rundeck to provide a pull down list of artfacts eligible for deployment.

like image 156
Mark O'Connor Avatar answered Sep 24 '22 14:09

Mark O'Connor


See download-artifact-from-nexus.sh script at https://github.com/cescoffier/puppet-nexus/tree/master/files

In my case, I modified it to use wget instead of curl. For some reason, curl wouldn't work for me.

like image 21
David I. Avatar answered Sep 21 '22 14:09

David I.