做好备份,还原,一套打包带走
略
略
制作jenkins的linus服务service
/usr/lib/systemd/system目录下新建一个 jenkins.service的文件
[UNIT]
Description=Media wanager Service
After=network.target
[Service]
Type=forking
# 启动脚本
ExecStart=/root/jenkins/start.sh start
# 停止脚本
ExecStop=/root/jenkins/start.sh stop
PrivateTmp=True
[Install]
WantedBy=multi-user.target
启动脚本
#!/bin/bash
CMD=$1
JENKINS_HOME=/root/jenkins/data
export JENKINS_HOME
case $CMD in
start)
nohup /root/java/jdk1.8/bin/java -jar /root/jenkins/jenkins.war --config=/root/jenkins/config --webroot=/root/jenkins/home --pluginroot=/root/jenkins/plugin --httpPort=28080 > /root/jenkins/info.log &
echo $! > /root/jenkins/pid
;;
stop)
pid=`cat /root/jenkins/pid`
kill -9 $pid
;;
*)
echo "Usage: start start | stop .Or use systemctl start | stop | restart MediaManager.service "
;;
esac
# 开机自启
systemctl enable jenkins
# 查看状态
systemctl status jenkins
# 启动jenkins
systemctl start jenkins
# 停止jenkins
systemctl stop jenkins
#!/bin/bash
# 备份jenkins脚本
# jenkins 数据目录
home=/root/jenkins
# jenkins 备份目录
backup_dir=/root/backup
# 时间
date=`date +%Y%m%d`
zip -r ${backup_dir}/jenkins_backup_${date}.zip ${home}
# 编辑crontab
crontab -e
# 查看crontab
crontab -l
crontab -e
5 0 1 * * -u root /root/jenkins/backup.sh
maven-checkstyle-plugin checkstyle代码风格检测
check-staging-properties-maven-plugin properties的配置文件一致检查
使用ssh配置集群即可
ssh-keygen -t rsa -C "suwenguang@cainiao.com" -b 4096
# 查看参数选项
java -jar jenkins.war.jar --help
java -jar jenkins.war --config=/root/jenkins/config --webroot=/root/jenkins/home --pluginroot=/root/jenkins/plugin --httpPort=28080
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins
# 启动jenkins 指定插件路径,指定端口
java -jar jenkins.war.jar --webroot=/root/suveng/jenkins/home --pluginroot=/root/suveng/jenkins/plugin --httpPort=13880
Jenkins有点特殊. Jenkins如果用来做持续集成,需要本地一些语言的环境,但是如果是用来打包docker镜像,则简单的多, 如果是springboot打包成docker,则需要maven和java的配置 这个时候需要挂载本机的一些开发环境. 比如挂载jdk,挂载maven,这里不记录
docker run -u root --name jenkins
-d
-p 9998:8080
-p 9999:50000
-v /data/docker/jenkins/jenkins-data:/var/jenkins_home
-v /usr/local:/env
-v /var/run/docker.sock:/var/run/docker.sock
jenkinsci/blueocean
maven.test.jvmargs 介绍:
jenkins 钉钉插件:
jenkins jacoco插件:
https://www.jianshu.com/p/0ecedb072c69
19. crontab 定时任务 — Linux Tools Quick Tutorial
pipeline语法: https://blog.csdn.net/u011541946/article/details/83278214