Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I automatically deploy a war from Nexus to Tomcat?

How can I automatically deploy a war from Nexus to Tomcat?

I have a maven web project which gets built and deployed (both SNAPSHOT and release versions) on Nexus successfully. I would like to know if there is feature/plugin in Nexus where it picks the released war and deploys on remote Tomcat automatically?

I know that you can deploy the war to remote Tomcat using maven-tomcat-plugin but would like to know if there is an alternative solution.

Please guide.

like image 338
Nital Avatar asked Jan 10 '23 23:01

Nital


1 Answers

Typically you'd use a CI tool like Jenkins to run the Maven build that publishes your War file into Nexus. Nexus would then be used by whatever tool you're using to push the War onto the target tomcat environment:

enter image description here

There are lots and lots of options.

Jenkins post build SSH script

Run a post-build SSH task from Jenkins that does something like this on the target tomcat server:

curl "http://myrepo/nexus/service/local/artifact/maven/redirect?r=releases&g=myorg&a=myapp&v=1.1&e=war" \
     -o /usr/local/share/tomcat7/webapps/myapp.war
service tomcat7 restart

Rundeck

My preference is to use Rundeck for deployments, because it has a Nexus plugin, providing convenient drop-down menus of available releases.

There is also a Rundeck plugin for Jenkins that can be used to orchestrate a CI process with Jenkins performing the build, hand-over to Rundeck for deployment, followed by a Jenkins call-back to run the integration tests.

Chef

I also use chef which can be used to automatically deploy software in a pull fashion.

The artifact cookbook has direct support for Nexus, whereas the application_java cookbook uses a more generic "pull from a URL" approach that also works well.

.. ..

The list goes on, so I hope this helps.

like image 183
Mark O'Connor Avatar answered Jan 16 '23 18:01

Mark O'Connor