一、安装jenkins
https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/ #清华yum源
yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
[root@jenkins ~]# yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
[root@jenkins ~]# wget https://pkg.jenkins.io/redhat/jenkins-2.73-1.1.noarch.rpm
[root@jenkins ~]# rpm -ivh jenkins-2.73-1.1.noarch.rpm
[root@jenkins ~]# /etc/init.d/jenkins start #启动jenkins
[root@jenkins ~]# cat /var/lib/jenkins/secrets/initialAdminPassword #初始登陆密码
[root@jenkins ~]# ll /var/lib/jenkins/plugins/ #jenkins插件目录
[root@jenkins ~]# rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins # 日志切割
/etc/sysconfig/jenkins # 配置文件路径
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war # jenkins war包路径
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins # jenkins家目录
/var/log/jenkins # 日志路径
二、配置jenkins与Gitlab集成
1、创建一个新任务
2、配置邮件通知
3、配置git访问
4、配置Gitlab自动触发jenkins部署
5、把gitlab上的Private Token复制到jenkins里的API token里
6、在jenkins里点击系统管理里的系统设置配置Gitlab
把上图中的Gitlad Cl Server URL后的地址和Secret token填写到Gitlab中后点保存测试
参考文档:
https://www.abcdocker.com/abcdocker/2041
http://dwz.cn/6j9fHv #自动化部署代码实践