准备工作
- centos7.9
- docker环境
Jenkins 安装与配置
-
使用docker安装jenkins
bashdocker run -d -u root -v jenkins_home:/var/jenkins_home -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 --restart=always jenkins/jenkins:lts-jdk11
-
获取密码
bashdocker ps docker exec -u 0 -it container_id /bin/bash cat /var/jenkins_home/secrets/initialAdminPassword
4. 插件安装
Generic Webhook Trigger
Publish over SSH
nodejs
ssh
Maven Integration
#Generic Webhook Trigger配置
^(refs/heads/master)_(jello-web)$
$ref_$name
jar包进程脚本
bash#!/bin/bash SERVER_NAME=jello JAR_NAME=jello-0.0.1-SNAPSHOT echo "查询进程id-->$SERVER_NAME" PID=`ps -ef | grep "$SERVER_NAME" | grep -v grep | awk '{print $2}'` echo "得到进程ID:$PID" echo "结束进程" for id in $PID do kill -9 $id echo "killed $id" done echo "结束进程完成" cd /www/wwwroot/api.jello.annyyy.com/ chmod 755 $JAR_NAME.jar nohup java -jar $JAR_NAME.jar & echo '执行完了构建'
bashnpm ci npm run build tar -czvf dist.tar.gz \.next env public package.json \.npmrc
F&Q
- 构建springboot不能自动结束
bashnohup java -jar test.jar >start.log 2>&1 &
- 时间比主机时间慢8小时
一次性设置,重启无效
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone','Asia/Shanghai')
永久设置
bashdocker exec -it -u root container_id bash cat /etc/timezone echo 'Asia/Shanghai' > /etc/timezone