Linux Jenkins 安装部署

一、安装必要环境

1、安装JDK

yum search java | grep jdk
yum install 合适版本全称

2、安装Maven

yum install maven

3、安装Git

yum install git

二、安装Jenkins

1、安装Jenkins包,启动服务

安装-直接查看官方教程

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

安装完成后,最好确认一下配置,修改端口等配置

vim /etc/sysconfig/jenkins

启动之前,确认jenkins服务已正常配置,然后启动:

service jenkins status
# 输出信息
 jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)
service jenkins start
异常一

Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

原因:Jenkins默认配置了常用JDK路径、本机JDK路径不在其中

vim /etc/rc.d/init.d/jenkins

candidates="
/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-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.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
"

解决方法 修改Jenkins启动脚本

vim /etc/rc.d/init.d/jenkins

添加jdk 本机JDK地址
/usr/java/jdk1.8.0_181/bin/java
异常二

Starting jenkins (via systemctl): Warning: jenkins.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.

systemctl daemon-reload

2、打开可操作页面:

然后 ip:端口 即可正常访问

image-20191113152944745.png

三、进行jenkins基础配置

1、获取密码

cat /var/lib/jenkins/secrets/initialAdminPassword
image-20191113153654959.png

2、安装插件

安装默认即可

image-20191113153800765.png

3、创建管理员用户

image-20191113153910067.png

你可能感兴趣的:(Linux Jenkins 安装部署)