1、下载镜像
docker pull jenkins/jenkins:lts
1
2、准备目录
mkdir -p /server/jenkins
# 如果创建后没有启动,请判断是否为目录权限问题
chmod -R 777 /server/jenkins
3、准备JAVA_HOME目录
echo $JAVA_HOME
# 进入jenkins容器
docker exec -it jks /bin/bash
# 查看密码
cat /var/jenkins_home/secrets/initialAdminPassword
/opt/java/openjdk
安装插件
下面xxxx 代表项目名 (xxxx.jar与项目jar保持一致)
#!/bin/bash
echo "xxxx start"
SERVER_NAME="xxxx"
source /etc/profile
cd /server/app
echo "查询进程id-->$SERVER_NAME"
PID=`ps -ef | grep "$SERVER_NAME" |grep -v grep| awk '{print $2}'`
echo "得到进程ID:$PID"
if [ "$PID" = "" ]; then
echo "线程不存在"
else
echo "结束线程"
for id in $PID
do
kill -9 $id
echo "killed $id"
done
fi
nohup java -Dcatalina.home=/server/app -jar -Dspring.profiles.active=dev xxxx.jar > xxxx.log 2>&1 &
echo "xxxx start finish"
ps aux |grep java (查看进程)