Jenkins

作者: linux_Alex | 来源:发表于2018-07-15 15:37 被阅读0次

开发(git) -->git主库-->jenkins(git+jdk+tomcat+maven打包+测试)-->发布到tomcat服务器

Jenkins 是一个开源的,提供友好操作界面的持续集成(CI)工具

Jenkins的主要目标 是监控软件开发流程,快速显示问题

CI

英文全称:Continuous  Integration

中文全称:持续集成工具

持续集成是一种软件开发实践。在持续集成中,团队成员频繁集成他们的工作成果,一般每人每天至少集成一次,也可以多次。每次集成会经过自动构建(包括自动测试)的检验,以尽快发现集成错误。

SCM

英文全称:Source  Control Management (Software Version Control)

中文全称:源码控制管理软件 版本控制

Jenkins将代码进行统一的编译、打包和发布到tomcat容器中进行发布

Jenkins优点

                  易于安装

                  易于配置

                  文件识别

                  分布式构建

                  支持插件

部署:

         部署Git(编译安装方式)

                  [root@server tmp]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y

                  git官网下载最新版本GIT

                  https://mirrors.edge.kernel.org/pub/software/scm/git/

                  软件:git-2.9.5.tar.gz

                  安装git:

                  解压并cd到解压目录

                  # make prefix=/usr/local/git all

                  # make prefix=/usr/local/git install

                  修改环境变量:

                  [root@server bin]# vim /etc/bashrc

                  PATH=$PATH:$HOME/bin:/usr/local/git/bin

                  [root@server bin]#source /etc/bashrc

                  测试是否安装成功:

                  [root@server ~]#git --version

                  git version 2.9.5

         JDK环境部署

                  下载软件:

                  jdk-8u151-linux-x64.tar.gz

                  注意:不能用jdk9和jdk10

                  解压安装:

                  [root@jenkins /]# tar xvzf jdk-8u151-linux-x64.tar.gz -C /usr/local/

                  [root@jenkins /]# cd /usr/local/

                  [root@jenkins local]# mv jdk1.8.0_151 jdk

                  修改环境变量:

                  #vim  /etc/bashrc    追加以下配置

                  JAVA_HOME=/usr/local/jdk

                  export PATH=$PATH:$JAVA_HOME/bin

                  # source  /etc/bashrc

         部署Maven

                  Maven是基于项目对象模型

                  下载和解压Maven:

                  官方下载地址:http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.3/binaries/

                  apache-maven-3.5.3-bin.tar.gz

                  [root@server 1802]# tar xvzf apache-maven-3.5.3-bin.tar.gz -C /usr/local/

                  [root@server 1802]# mv /usr/local/apache-maven-3.5.3/ /usr/local/maven

                  修改环境变量

                  [root@server 1802]# vim /etc/bashrc

                  export M2_HOME=/usr/local/maven

                  export M2=$M2_HOME/bin

                  PATH=$M2:$PATH:$HOME/bin:/usr/local/git/bin

                  export JAVA_HOME=/usr/local/jdk

                  export PATH

                  [root@server 1802]# source /etc/bashrc

                  测试maven是否安装成功:

                  [root@server 1802]# mvn -version

                  Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)

                  Maven home: /usr/local/maven

                  Java version: 9.0.1, vendor: Oracle Corporation

                  Java home: /usr/local/jdk

                  Default locale: en_US, platform encoding: UTF-8

                  OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"

         部署tomcat

                  安装Jdk8.0 注意:是8版本的JDK

                  官网下载tomcat:

                  apache-tomcat-9.0.1.tar.gz

                  解压部署:

                  [root@server 1802]# tar xvzf apache-tomcat-9.0.1.tar.gz  -C /usr/local/

                  [root@server 1802]# mv /usr/local/apache-tomcat-9.0.1/ /usr/local/tomcat

                  定义Tomcat所需环境变量:

                  # vim /etc/profile//定义Tomcat环境变量

                  CATALINA_HOME=/usr/local/tomcat //Tomcat安装目录

                  export CATALINA_HOME

                  # source /etc/profile

                  启动tomcat:

                  #/usr/local/tomcat/bin/startup.sh

                  关闭tomcat:

                  #/usr/local/tomcat/bin/shutdown.sh

                  配置tomcat的角色和用户(暂时用不到):

                  在tomcat目录conf文件夹下tomcat-users.xml

                  <role  rolename="manager-gui"/>

                  <role  rolename="abmin"/>

                  <role  rolename="manager"/>

                  <role  rolename="manager-script"/>

                  <role  rolename="tomcat" password="tomcat" roles="manager-gui,admin,managre,manager-script"/>

         部署Jenkins:

                  官网下载jenkins:

                  http://updates.jenkins-ci.org/download/war/

                  软件名称:

                  jenkins.war

                  部署jenkins.war到tomcat下:

                  [root@server 1802]# cp jenkins.war  /usr/local/tomcat/webapps/

                  启动tomcat: 注意启动tomcat会自动解压webapps下的war包

                  [root@server webapps]# /usr/local/tomcat/bin/startup.sh

                  Using CATALINA_BASE:    /usr/local/tomcat

                  Using CATALINA_HOME:  /usr/local/tomcat

                  Using CATALINA_TMPDIR: /usr/local/tomcat/temp

                  Using JRE_HOME:    /usr/local/jdk

                  Using CLASSPATH:  /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

                  Tomcat started.

                  登陆jenkins:

                  浏览器:http://127.0.0.1:8080/jenkins/

                                                                              后面具体步骤可以在网上搜到,图片就不上传了

相关文章

网友评论

      本文标题:Jenkins

      本文链接:https://www.haomeiwen.com/subject/khuppftx.html