Jenkins 部署详解

 Jenkins持续集成组件


  1. 自动构建过程JOB,JOB的功能主要是:获取SVN/GIT源码、自动编译、自动打包、部署分发和自动测试等;
  2. 源代码存储库,开发编写代码需上传至SVN、GIT代码库中,供Jenkins来获取;
  3. Jenkins持续集成服务器,用于部署Jenkins UI、存放JOB工程、各种插件、编译打包的数据等。

 

Jenkins软件平台部署实战


Jenkins官网免费获取Jenkins软件,官网地址为:http://mirrors.jenkins-ci.org/下载稳定的Jenkins版本(https://mirror.tuna.tsinghua.edu.cn/jenkins/war/2.175/jenkins.war )。由于Jenkins是基于Java开发的一种持续集成工具,所以Jenkins服务器需安装JAVA JDK开发软件。Jenkins平台搭建步骤如下:

 

 

热部署jenkins 


 配置你的Tomcat,并且进行优化

    <Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
               connectionTimeout="30000"
               URIEncoding="UTF-8"
               minSpareThreads="100"
               maxThreads="4096"
               acceptCount="10000"
               enableLookups="false" 
               disableUploadTimeout="true"
               redirectPort="8443" />
    <Connector port="8009" protocol="org.apache.coyote.ajp.AjpNio2Protocol" redirectPort="8443" />

[root@localhost ~]# vim /usr/local/tomcat/bin/catalina.sh 
JAVA_OPTS="-server -Xms900m -Xmx900m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:MaxNewSize=512m"
[root@localhost ~]# ps -ef | grep java
 -server -Xms900m -Xmx900m -XX:PermSize=256m -XX:MaxPermSize=512m 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
  • unpackWARs="true"  是否自动解压war包
  • autoDeploy="true"   自动部署,回头你只要往我的站点目录下/code丢一个war包,不需要重启tomcat,自动帮你解压,然后就可以访问了
[root@localhost ~]# mv jenkins.war ROOT.war
[root@localhost ~]# cp ROOT.war /usr/local/tomcat/webapps/

#查看日志可以看到tomcat解压并且部署上传的war包
27-Oct-2020 17:37:52.957 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.undeploy Undeploying context []
27-Oct-2020 17:37:53.129 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/ROOT.war
Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
27-Oct-2020 17:38:18.475 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/ROOT.war has finished in 25,346 ms
27-Oct-2020 17:38:24.980 INFO [pool-7-thread-1] jenkins.InitReactorRunner$1.onAttained Started initialization
27-Oct-2020 17:38:25.103 INFO [pool-7-thread-1] jenkins.InitReactorRunner$1.onAttained Listed all plugins
27-Oct-2020 17:38:32.872 INFO [pool-7-thread-2] jenkins.InitReactorRunner$1.onAttained Prepared all plugins
27-Oct-2020 17:38:32.907 INFO [pool-7-thread-2] jenkins.InitReactorRunner$1.onAttained Started all plugins
27-Oct-2020 17:38:32.936 INFO [pool-7-thread-2] jenkins.InitReactorRunner$1.onAttained Augmented all extensions
............................................................................
27-Oct-2020 17:45:30.725 INFO [pool-7-thread-2] jenkins.InitReactorRunner$1.onAttained Completed initialization
27-Oct-2020 17:45:30.930 INFO [Jenkins initialization thread] hudson.WebAppMain$3.run Jenkins is fully up and running


[root@localhost ~]# ls /usr/local/tomcat/webapps/
docs  examples  host-manager  manager  ROOT  ROOT.war

部署成功之后输入密码

[root@localhost ~]# cat /root/.jenkins/secrets/initialAdminPassword
ee0d75d5495b4ee1a522d6947a060065

 

插件的部署


 这里选择安装所有的插件,可能会很多插件下载失败,没关系我的插件已经打包成一个文件了。 

 很不幸这里插件下载失败了,点击继续

来到主页创建job 可以看到这里少了很多插件,插件存放的位置在/root/.jenkins/plugins下面

 将所有的插件移动到该目录下面

[root@localhost ~]# tar xf root_jenkins.tar.gz 
[root@localhost ~]# cd root_jenkins
[root@localhost root_jenkins]# ls
[root@localhost root_jenkins]# ls -a
.  ..  .jenkins
[root@localhost root_jenkins]# ls .jenkins/plugins/
ace-editor                              github-api                matrix-project                        scm-api
ace-editor.jpi                          github-api.jpi            matrix-project.jpi                    scm-api.jpi
ant                                     github-branch-source      maven-plugin                          script-security
antisamy-markup-formatter               github-branch-source.jpi  maven-plugin.jpi                      script-security.jpi
antisamy-markup-formatter.jpi           github.jpi                momentjs                              ssh-credentials
ant.jpi                                 git.jpi                   momentjs.jpi                          ssh-credentials.jpi


[root@localhost ~]# mv root_jenkins/.jenkins/* .jenkins/

重启tomcat可以看到插件都加载进来了 ,至此就可以进行使用了

©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页