1.什么是Jenkins?
jerkins官方的描述作为领先的开源自动化服务器,Jenkins 提供了数百个插件来支持构建、部署和自动化任何项目。
jenkins是一个开源提供友好界面的持续集成工具,是由Java开发。它本身不做什么事情,所有的工作都是通过插件的方式来完成调度与工作;
2.Jenkins的安装
官方地址: https://www.jenkins.io/download/
清华大学镜像站: https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/
2.1下载Jenkins的rpm包
目前最新版本2.346.3
安装jenkins2.346.3
通过rpm包安装Jenkins
# 通过清华大学源来安装,因为国外速度太慢。
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.346-1.1.noarch.rpm --no-check-certificate
2.2关闭防火墙selinux
[root@localhost /]# setenforce 0
[root@localhost ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
一定要确保字符集为 LANG="en_US.UTF-8"否则Jenkins汉化会汉化一部分;
[root@localhost /]# LANG="en_US.UTF-8"
2.3安装java-jdk
# 安装java
[root@localhost ~]# yum install java-11-openjdk-devel -y
# 查看java版本
[root@localhost ~]# java --version
openjdk 11.0.16 2022-07-19 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.16.0.8-1.el7_9) (build 11.0.16+8-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.16.0.8-1.el7_9) (build 11.0.16+8-LTS, mixed mode, sharing)
2.4 安装Jenkins
[root@localhost ~]# yum localinstall
anaconda-ks.cfg .bash_logout .bashrc jenkins-2.346-1.1.noarch.rpm
.bash_history .bash_profile .cshrc .tcshrc
[root@localhost ~]# yum localinstall jenkins-2.346-1.1.noarch.rpm -y
已加载插件:fastestmirror
正在检查 jenkins-2.346-1.1.noarch.rpm: jenkins-2.346-1.1.noarch
jenkins-2.346-1.1.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 jenkins.noarch.0.2.346-1.1 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================================================================================
正在安装:
jenkins noarch 2.346-1.1 /jenkins-2.346-1.1.noarch 87 M
事务概要
====================================================================================================================================================================================================
安装 1 软件包
总计:87 M
安装大小:87 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : jenkins-2.346-1.1.noarch 1/1
验证中 : jenkins-2.346-1.1.noarch 1/1
已安装:
jenkins.noarch 0:2.346-1.1
完毕!
2.5配置Jenkins
修改用户Jenkins为root即可
[root@localhost ~]# vim /etc/sysconfig/jenkins
JENKINS_USER="root"
2.6启动Jenkins
[root@localhost /]# systemctl start jenkins
[root@localhost /]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since 四 2022-08-25 18:42:46 CST; 4s ago
Docs: man:systemd-sysv-generator(8)
Process: 11659 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Main PID: 11431 (code=exited, status=143)
CGroup: /system.slice/jenkins.service
└─11687 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins...
8月 25 18:42:46 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
8月 25 18:42:46 localhost.localdomain runuser[11664]: pam_unix(runuser:session): session opened for user root by (uid=0)
8月 25 18:42:46 localhost.localdomain runuser[11664]: pam_unix(runuser:session): session closed for user root
8月 25 18:42:46 localhost.localdomain jenkins[11659]: Starting Jenkins [ 确定 ]
8月 25 18:42:46 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.
2.7确认服务是没有问题的
这里打开有一点慢稍微等一下。
2.8 解锁Jenkins
通过cat查看Jenkins解锁密码
[root@localhost /]# cat /var/lib/jenkins/secrets/initialAdminPassword
2fec9c61b9ec474eaa0b3105c5xxxxx
2.9 安装插件;
这里选择推荐的插件安装的话,因为源是在国外的,所以安装非常慢,可以选择第二个;
2.10 设置管理员
这里选择使用admin账户继续
2.11设置站点
保存完成即可
2.12完成安装
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/282223.html