、Jenkins安装

1)Jenkins介绍

1)一个自动构建过程,包括自动编译,分发,部署和测试,是持续的软件版本发布,测试项目
2)一个代码存储库,即需要版本控制软件来保障代码的可维护性,同时作为构建过程的素材库,例如svn,git代码库
3)监控外部调用执行的工作

2)Jenkins的安装环境

[root@linux-host2 ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
[root@linux-host2 ~]# uname -r
3.10.0-693.el7.x86_64
[root@linux-host2 ~]# uname -m
x86_64
[root@linux-host2 ~]# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
centos7内安装

3)Jenkins的安装方法

3.1)yum install jenkins -y 方式

yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key
yum install jenkins -y
yum安装方式

3.2)rpm包安装

Jenkins下载地址:https://pkg.jenkins.io/redhat-stable/
执行过程
wget https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.32.2-1.1.noarch.rpm
[root@linux-host2 tools]# rpm -ivh jenkins-2.32.2-1.1.noarch.rpm
[root@linux-host2 tools]# rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
[root@linux-host2 tools]# systemctl start jenkins
[root@linux-host2 tools]# ss -lnt
State      Recv-Q Send-Q           Local Address:Port                          Peer Address:Port              
LISTEN     0      128                          *:22                                       *:*                  
LISTEN     0      100                  127.0.0.1:25                                       *:*                  
LISTEN     0      50                          :::8080                                    :::*                  
LISTEN     0      128                         :::22                                      :::*                  
LISTEN     0      100                        ::1:25                                      :::*  
执行过程

4)启动Jenkins

service jenkins start   # centos6启动
systemctl start jenkins # centos7启动
chkconfig jenkins on    # 设置开机自启动

5)访问Jenkins网页

1.访问Jenkins:10.0.0.101:8080/
2.查找admin默认密码
 cat /var/lib/jenkins/secrets/initialAdminPassword

6)安装默认插件

7) Jenkins的目录文件介绍

[root@linux-host2 tools]# rpm -ql jenkins
/etc/init.d/jenkins            #启动脚本
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins           #配置文件
/usr/lib/jenkins    
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins          #程序目录
/var/lib/jenkins             #主目录
/var/log/jenkins        #日志文件
[root@linux-host2 tools]# grep ^[a-Z]  /etc/sysconfig/jenkins
JENKINS_HOME="/var/lib/jenkins"
JENKINS_JAVA_CMD=""
JENKINS_USER="jenkins"
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
JENKINS_PORT="8080"
JENKINS_LISTEN_ADDRESS=""
JENKINS_HTTPS_PORT=""
JENKINS_HTTPS_KEYSTORE=""
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
JENKINS_HTTPS_LISTEN_ADDRESS=""
JENKINS_DEBUG_LEVEL="5"
JENKINS_ENABLE_ACCESS_LOG="no"
JENKINS_HANDLER_MAX="100"
JENKINS_HANDLER_IDLE="20"
JENKINS_ARGS=""
Jenkins目录文件介绍

8)Jenkins版本升级

8.1)查看当前版本

8.2)执行步骤

执行步骤
1.新版本Jenkins.war包下载地址:http://updates.jenkins-ci.org/download/war/
2.关闭Jenkins。
3.备份原来版本的war包。
4.上传新版本的war包到/usr/lib/jenkins/下

实际命令操作
[root@linux-host2 tools]# systemctl stop jenkins.service 
[root@linux-host2 tools]# ss -lnt|grep 8080
[root@linux-host2 jenkins]# cd /usr/lib/jenkins/
[root@linux-host2 jenkins]# mv jenkins.war jenkins-3.23.2.war
wget http://mirrors.shu.edu.cn/jenkins/war-stable/2.46.2/jenkins.war
[root@linux-host2 jenkins]# ll
total 136936
-rw-r--r-- 1 root root 69874457 Feb  1  2017 jenkins-3.23.2.war
-rw-r--r-- 1 root root 70342163 Mar 28 11:34 jenkins.war
[root@linux-host2 jenkins]# systemctl start jenkins.service      
[root@linux-host2 jenkins]# ss -lnt|grep 8080                 
LISTEN     0      50          :::8080                    :::*
升级具体步骤

 二、Jenkins的基本使用

1)系统设置

 

 三、插件安装

1)安装gitlab插件

 1.1)插件安装的其他方法

1.2)直接拷贝安装好的插件文件到指定位置重启Jenkins

[root@node01 plugins]# pwd
/var/lib/jenkins/plugins

 1.3)使用git向gitlab拉取代码,可在全局配置私钥。

1.4) 保存,立即构建。测试是否能拉取代码

 

posted on 2018-12-24 11:01  可口_可乐  阅读(294)  评论(0编辑  收藏  举报