1.配置文件JENKINS.sh
#!/bin/bash
# 导入环境变量
export JENKINS_HOME=/home/jenkins
export JAVA_HOME=/home/java/jdk1.8.0_191
cd $JENKINS_HOME
pid=`ps -ef | grep jenkins.war | grep -v 'grep'| awk '{print $2}'`
if [ "$1" = "start" ];then
if [ -n "$pid" ];then
echo 'jenkins is running...'
else
### java启动服务 配置java安装根路径,和启动war包存的根路径
nohup $JAVA_HOME/bin/java -Xms128m -Xmx128m -jar $JENKINS_HOME/jenkins.war --ajp13Port=-1 --httpPort=8081 >/dev/null 2>&1 &
fi
elif [ "$1" = "stop" ];then
exec ps -ef | grep jenkins | grep -v grep | awk '{print $2}'| xargs kill -9
echo 'jenkins is stop...'
else
echo "Please input like this:"./jenkins.sh start" or "./jenkins stop""
fi
2.启动:
sh /home/jenkins/jenkins.sh start
3.停止:
sh /home/jenkins/jenkins.sh stop
花粉社群VIP加油站
猜你喜欢