Tomcat script does not work when run from Hudson

I am trying to run a script that stops and runs Tomcat on linux.

When I run it from the command line, it works fine. But it doesn't seem to work when I run the same script from the Execute Shell build step in a Jenkins / Hudson job. Jenkins does not report any errors, but if I try to go to the tomcat page, I get a page error message.

So, Jenkins seems to be able to stop the server, but does not bring him a backup.

I would be grateful for any help.

+8
linux tomcat hudson jenkins
source share
2 answers

Try disabling BUILD_ID in the 'shell execute' block. You may not even need to use nohup in this case.

 BUILD_ID= ./your_hudson_script_that_starts_tomcat.sh 
+18
source share

Without seeing your script, it is difficult to give an exact answer. However, you can try adding the following to the top of your script (assuming it's a bash script):

 # Trace executed commands. set -x # Save stdout / stderr in files exec >/tmp/my_script.stdout exec 2>/tmp/my_script.stderr 

You can also try adding

 set -e 

to exit the shell immediately if the command returns an error status.

If Hudson seems to be killing Tomcat, then you can run it in nohup (if you haven't already):

 nohup bin/startup.sh >/dev/null 2>&1 & 
+1
source share

All Articles