centos7部署jenkins war包
1、下载地址
https://get.jenkins.io/war-stable/
2、启动
#前台启动
java -jar jenkins.war
#后台启动
nohup java -jar jenkins.war &
默认端口8080,默认JENKINS_HOME目录:~/.jenkins
3、启动脚本
#!/bin/bash
# 导入环境变量
export JENKINS_HOME=/data/jenkins
export JAVA_HOME=/data/java
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 -Xmx256m -jar $JENKINS_HOME/jenkins.war --ajp13Port=-1 --httpPort=8080 >/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 "脚本使用方法:"./jenkins.sh start" 或者 "./jenkins stop""
fi