Jenkins的安装及汉化、安装插件、创建一个关联shell的任务并执行
一、安装jenkins
- 关闭防火墙
- 关闭selinux
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# setenforce 0
[[email protected] ~]# systemctl disable firewalld
[[email protected] ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
部署java
[[email protected] ~]# yum -y install java-1.8.0
部署jenkins(在这里我通过rpm包安装由于网络慢的缘由)
[[email protected] ~]# rpm -ivh jenkins-2.222.4-1.1.noarch.rpm
[[email protected] ~]# systemctl start jenkins
[[email protected] ~]# systemctl enable jenkins
更新jenkins配置
[[email protected] ~]# vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url> #改为国内的网站
</site>
</sites>
重启jenkins
[[email protected] ~]# systemctl restart jenkins
配置下载插件加速(如果没有这个文件,请启动jenkins稍等片刻)
[[email protected] ~]# cd /var/lib/jenkins/updates/
[[email protected] updates]# sed -i 's/http:\/\/updates.jenkinsci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json
[[email protected] updates]# sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
登录jenkins
二、汉化jenkins
首先安装两个插件
- chinese
- locale
三、安装插件
- git
- gitlab
四、创建一个关联shell的任务
- 当执行这个任务的时候,指定的shell脚本就会被执行
五、创建一个关联gitlab的任务
- 当执行这个任务的时候,就会从gitlab中拉取代码
首先在gitlab节点安装上git组件
# yum install git -y
最好进行一次拉取代码测试
git clone http://192.168.31.64/root/zxhk.git
注意
- 在jenkis中安装git和gitlab插件
- 在jenkins所在节点要安装git