CentOS7 安装Jenkins

388 阅读1分钟

安装JDK

下载Jenkines

wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.319.1-1.1.noarch.rpm --no-check-certificate

安装Jenkines

[root@localhost yhwl]# rpm -ivh jenkins-2.319.1-1.1.noarch.rpm 
警告:jenkins-2.319.1-1.1.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 45f2c3d5: NOKEY
错误:依赖检测失败:
        daemonize 被 jenkins-2.319.1-1.1.noarch 需要

#解决

[root@localhost yhwl]#  yum  -y install epel-release
已加载插件:fastestmirror
xxx
已安装:
  epel-release.noarch 0:7-11

[root@localhost yhwl]# yum -y install daemonize
已加载插件:fastestmirror
xxx
已安装:
  daemonize.x86_64 0:1.7.7-1.el7 

再次安装

[root@localhost yhwl]# rpm -ivh jenkins-2.319.1-1.1.noarch.rpm 
警告:jenkins-2.319.1-1.1.noarch.rpm:V4 RSA/SHA512 Signature, 密钥 ID 45f2c3d5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:jenkins-2.319.1-1.1              ################################# [100%]

配置Jenkins

# 修改配置文件,port等
vim /etc/sysconfig/jenkins

## Type:        integer(0:65535)
## Default:     8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8088"

启动Jenkins

[root@localhost yhwl]# systemctl status jenkins.service

image.png

解决


[root@localhost yhwl]# whereis java
java: /home/yhwl/jdk1.8.0_271/bin/java

#配置java实际安装路径
vim /etc/init.d/jenkins

/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
/home/yhwl/jdk1.8.0_271/bin/java

#保存退出

再次启动

[root@localhost yhwl]# systemctl start jenkins
Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units.

[root@localhost yhwl]# systemctl daemon-reload
[root@localhost yhwl]# systemctl start jenkins

检测

[root@localhost yhwl]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since 一 2022-01-17 14:55:10 CST; 22s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/jenkins.service
           └─24345 /home/yhwl/jdk1.8.0_271/bin/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --http...

1月 17 14:55:10 localhost.localdomain systemd[1]: Starting LSB: Jenkins Automation Server...
1月 17 14:55:10 localhost.localdomain jenkins[24341]: Starting Jenkins [  OK  ]
1月 17 14:55:10 localhost.localdomain systemd[1]: Started LSB: Jenkins Automation Server.