Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

auto start stop remote tomcat before redeploying war by jenkins (deploy plugin)

at the moment jenkins build my project and at the end the artifact is deployed on a remote tomcat via jenkins deploy plugin. the problem is that after several redeployments this process fails (sometimes tomcat hangs or (un)deployment fails). in all cases stopping tomcat and manually undeploying helps.

Is there a way to stop tomcat before building/deploying, delete the old war and appfolder, and restart tomcat before deploy plugin wants to deploy the artifact?

thx in advance

like image 679
dermoritz Avatar asked Feb 03 '12 11:02

dermoritz


1 Answers

You could write a batch file that does all the things mentioned:

  • stop tomcat
  • delete war files
  • start tomcat again

Then you can add a new pre/post build task in job configuration as execute batch and simply point it to run your batch file.

Added: You can use PsExec - http://technet.microsoft.com/en-us/sysinternals/bb897553 It allows you to run processes remotely. Put batch on remote machine and from local one using Jenkins run sth like this: PsExec.exe \xx.xx.x.x C:\MyScript.bat

like image 105
Arek Avatar answered Oct 11 '22 13:10

Arek