Jenkins Build tomcat restart 방법에 대한 포스팅입니다.
Jenkins -> sample project -> 구성 -> Build -> Execute shell
echo "------------------ sample deploy & sample tomcat restart ---------------------"
cp /server/jenkins_home/workspace/sample/target/sample-0.0.1-SNAPSHOT-*.war /server/instance/sample/webapps/ROOT.war
sleep 5
if [ ! -z "`ps -eaf | grep -v "grep" | grep java | grep /server/instance/sample/bin`" ]; then
echo 'Tomcat was stop'
/server/instance/sample/bin/stop.sh
fi
if [ -f /server/instance/sample/bin/tomcat.pid ]; then
rm /server/instance/sample/bin/tomcat.pid
echo "tomcat PID File Delete"
fi
echo "tomcat restart now"
if [ -z "`ps -eaf | grep -v "grep" | grep java | grep /server/instance/sample/bin`" ]; then
BUILD_ID=dontKillMe /server/instance/sample/bin/start.sh
echo 'Tomcat restart succcessfully.'
fi
echo "Job finished"
echo "------------------ javadoc deploy & javadoc tomcat restart ---------------------"
cp /server/jenkins_home/workspace/sample/target/sample-0.0.1-SNAPSHOT-*.jar /server/instance/javadoc/webapps/sample.war
sleep 5
if [ ! -z "`ps -eaf | grep -v "grep" | grep java | grep /server/instance/javadoc/bin`" ]; then
echo 'javadoc Tomcat was stop'
/server/instance/javadoc/bin/stop.sh
fi
if [ -f /server/instance/javadoc/bin/tomcat.pid ]; then
rm /server/instance/javadoc/bin/tomcat.pid
echo "javadoc tomcat PID File Delete"
fi
echo "javadoc tomcat restart now"
if [ -z "`ps -eaf | grep -v "grep" | grep java | grep /server/instance/javadoc/bin`" ]; then
BUILD_ID=dontKillMe /server/instance/javadoc/bin/start.sh
echo 'javadoc Tomcat restart succcessfully.'
fi
echo "Job finished"

