一、jenkins是什么

Jenkins是一个开源的、可扩展的持续集成、交付、部署(软件/代码的编译、打包、部署)的基于web界面的平台。允许持续集成和持续交付项目,无论用的是什么平台,可以处理任何类型的构建或持续集成。

官网:https://jenkins.io/ 官方文档:https://jenkins.io/doc/

1.1 Jenkins特性

开源的java语言开发持续集成工具,支持CI,CD;

易于安装部署配置:可通过yum安装,或下载war包以及通过docker容器等快速实现安装部署,可方便web界面配置管理;

消息通知及测试报告:集成RSS/E-mail通过RSS发布构建结果或当构建完成时通过e-mail通知,生成JUnit/TestNG测试报告;

分布式构建:支持Jenkins能够让多台计算机一起构建/测试;

文件识别:Jenkins能够跟踪哪次构建生成哪些jar,哪次构建使用哪个版本的jar等;

丰富的插件支持:支持扩展插件,你可以开发适合自己团队使用的工具,如git,svn,maven,docker等。

jenkins功能:打包发布
jenkins是流程化工具

打包工具:

  • gradler
  • ant
  • maven
    打包工具版本必须一致

1.2 Jenkins部署

//关闭防火墙和selinux
[root@localhost ~]# systemctl disable --now firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config 
[root@localhost ~]# setenforce 0

// 安装openjdk、jenkins、tomcat
[root@localhost ~]# yum -y install java-17-openjdk*

[root@localhost ~]# wget https://get.jenkins.io/war-stable/2.303.2/jenkins.war

[root@localhost ~]# wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-9.0.54.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  apache-tomcat-9.0.54.tar.gz  jenkins.war

[root@localhost ~]# tar xf apache-tomcat-9.0.54.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-9.0.54  etc    include  lib64    sbin   src
bin                   games  lib      libexec  share
[root@localhost local]# mv apache-tomcat-9.0.54 jenkins
[root@localhost local]# ls
bin  games    jenkins  lib64    sbin   src
etc  include  lib      libexec  share
[root@localhost local]# cd jenkins/
[root@localhost jenkins]# ls
bin           CONTRIBUTING.md  logs       RELEASE-NOTES  webapps
BUILDING.txt  lib              NOTICE     RUNNING.txt    work
conf          LICENSE          README.md  temp

// 启动tomcat
[root@localhost jenkins]# ./bin/startup.sh 
Using CATALINA_BASE:   /usr/local/jenkins
Using CATALINA_HOME:   /usr/local/jenkins
Using CATALINA_TMPDIR: /usr/local/jenkins/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/jenkins/bin/bootstrap.jar:/usr/local/jenkins/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.
[root@localhost jenkins]# ss -antl
State  Recv-Q Send-Q        Local Address:Port   Peer Address:Port Process                                                            
LISTEN 0      128                 0.0.0.0:22          0.0.0.0:*                                                                       
LISTEN 0      100                       *:8080              *:*                                                                       
LISTEN 0      128                    [::]:22             [::]:*                                                                       
LISTEN 0      1        [::ffff:127.0.0.1]:8005              *:*                                                                     

访问Tomcat网页

// 因为项目是拿来给Jenkins用的,里面的除了ROOT,其他的都没什么用,可以删了,然后弄一个Jenkins放里面去就可以了
[root@localhost jenkins]# ls webapps/
docs  examples  host-manager  manager  ROOT
[root@localhost jenkins]# cd webapps/
[root@localhost webapps]# rm -rf docs  examples  host-manager  manager
[root@localhost webapps]# ls
ROOT
[root@localhost webapps]# pwd
/usr/local/jenkins/webapps

//把jenkins.war包cp到webapps下面去,过一会就会自动解压
[root@localhost webapps]# cp ~/jenkins.war .
[root@localhost webapps]# ls
jenkins.war  ROOT
[root@localhost webapps]# ls
jenkins  jenkins.war  ROOT

访问jenkins网页 http://192.168.57.135:8080/jenkins/login

[root@localhost webapps]# cat /root/.jenkins/secrets/initialAdminPassword
5e6a8cf74679048469c0b40e19e863e22     // 这就是上图的管理员密码

 

 

 

 

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐