Jenkins
介绍
Jenkins是一个开源的、可扩展的持续集成、交付、部署(软件/代码的编译、打包、部署)的基于web界面的平台。允许持续集成和持续交付项目,无论用的是什么平台,可以处理任何类型的构建或持续集成。
官网:https://jenkins.io/ 官方文档:https://jenkins.io/doc/
特性
开源的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
- 打包工具版本必须一致
部署
关闭防火墙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
[root@localhost ~]# getenforce
Disabled
安装openjdk、jenkins、tomcat
查看选择包
[root@localhost ~]# yum list all|grep openjdk
java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-javadoc-zip.noarch 1:1.8.0.201.b09-2.el8 AppStream
java-1.8.0-openjdk-src.x86_64 1:1.8.0.201.b09-2.el8 AppStream
java-11-openjdk.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-demo.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-devel.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-headless.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-javadoc.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-javadoc-zip.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-jmods.x86_64 1:11.0.2.7-2.el8 AppStream
java-11-openjdk-src.x86_64 1:11.0.2.7-2.el8 AppStream
[root@localhost ~]# yum -y install java-11-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 initial-setup-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 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 etc games include jenkins lib lib64 libexec sbin share src
[root@localhost local]# cd jenkins/
[root@localhost jenkins]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
开启服务
[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
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 100 *:8080 *:*
[root@localhost jenkins]# cd webapps/ [root@localhost webapps]# ls docs examples host-manager manager ROOT [root@localhost webapps]# rm -rf docs examples host-manager manager [root@localhost webapps]# ls ROOT [root@localhost webapps]# cp ~/jenkins.war . [root@localhost webapps]# ls jenkins.war ROOT [root@localhost webapps]# ls jenkins jenkins.war ROOT [root@localhost webapps]# cat /root/.jenkins/secrets/initialAdminPassword 8a874edaef5f4ff1a4f376c1d3eedb4b