Tomcat 7.x + Jenkins ver. 1.500
[Maven tomcat plugin을 이용하여 deploy -> reload 방법]
tomcat/conf/tomcat-users.xml
pom.xml
org.codehaus.mojo
tomcat-maven-plugin
1.1
UTF-8
war
http://localhost/manager/text
admin
admin
젠킨스 프로젝트 설정 Build 부분 명령어에 tomcat:redeploy tomcat:reload
[Shell 실행하여 Tomcat 재시작 방법]
jenkins에서 빌드 스크립트 종료 후 아래 shell 실행하면 정상 start 후 Process를 종료해버려서 기껏 올라간 Tomcat이 종료되는 문제가 발생한다.
그럴 경우 해당 프로젝트 설정에서 "This build is parameterized" 체크 하고, "Add Parameter" 에서 BUILD_ID 에다가 아무 값이나 셋팅!!
#!/bin/bash
echo "Shutdown tomcat now...."
bash /usr/local/tomcat/bin/shutdown.sh
echo "tomcat is now terminated..."
sleep 10
if [ -z "`ps -eaf | grep java | grep /usr/local/tomcat/bin`" ]; then
echo "Tomcat was terminated successfully."
else
ps -eaf | grep java | grep /usr/local/tomcat/bin | awk '{print $2}' |
while read PID
do
echo "Killing $PID... "
kill -9 $PID
echo "Tomcat is being shutdowned"
done
fi
echo "tomcat restart now"
/usr/local/tomcat/bin/./startup.sh
AA=`ps -eaf | grep java | grep /usr/local/tomcat/bin`
echo "AA: $AA"
if [ -z "`ps -eaf | grep java | grep /usr/local/tomcat/bin`" ]; then
echo "Error!!! Cannot start tomcat server."
else
echo "Tomcat restart succcessfully. "
fi
echo "Job finished"
[참조 shell] http://ausgang.egloos.com/2947190
startup.sh
#!/bin/sh
. ./env.sh
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.0.9
export CATALINA_BASE=/usr/local/tomcat/domains/$PROJECT_NM
export JAVA_OPTS="-Djava.awt.headless=true -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:+DisableExplicitGC"
export CATALINA_OPTS=$CATALINA_OPTS" -Dfile.encoding=UTF-8"
cd $CATALINA_HOME/bin
./startup.sh
AA=`ps -eaf | grep java | grep $WAS_PATH`
echo "AA: $AA"
if [ -z "`ps -eaf | grep java | grep $WAS_PATH`" ]; then
echo "Error!!! Cannot start tomcat server."
fi
while [ `netstat -an | grep :$WAS_PORT | grep LISTEN | wc | awk '{print $1}'` != 1 ]; do
echo -ne "."
sleep 1
done
echo "Check WAS Context Ready http://localhost:$WAS_PORT ..."
until [ "`curl --silent --show-error --connect-timeout 1 -I http://localhost:$WAS_PORT | grep 'Coyote'`" != "" ];
do
echo -ne "."
sleep 1
done
echo "Start WAS And Context $PROJECT_NM Tomcat Succcess"
shutdown.sh
#!/bin/sh
. ./env.sh
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-8.0.9
export CATALINA_BASE=/usr/local/tomcat/domains/$PROJECT_NM
$CATALINA_HOME/bin/./shutdown.sh
I=0
until [ "`ps -eaf | grep java | grep $WAS_PATH`" == "" ];
do
if [ $I == 5 ]; then
ps -ef | grep java | grep "$WAS_PATH " | awk {'print "kill -9 " $2'} | sh -x
break;
fi
let I=$I+1
echo Stop WAS Finish? Sleeping for 2 seconds
sleep 2
done