yum安装Jenkins最简单最全的教程
Jenkins是⽤java编写的开源持续集成⼯具,⽬前被国内外各公司⼴泛使⽤。本章教⼤家如何在linux服务器上安装Jenkins。需要先安装jdk
1.查看jdk版本,输⼊java -version,如果不是jdk1.8以上,需要安装jdk1.8。
2.新建/usr/java⽂件夹,下载,放在该⽬录下。linux安装jdk16
3.解压jdk,命令输⼊ tar -zxvf jdk-8u131-linux-x6
<。
4.配置环境变量,使⽤vi /etc/profile编辑profile⽂件,在/etc/profile底部加⼊下⾯内容:
export JAVA_HOME=/usr/java/jdk1.8.0_131
export CLASSPATH=.:$JAVA_HOME/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin
保存并退出编辑。
使⽤source /etc/profile让profile⽂件⽣效
三、yum安装Jenkins
这⾥推荐使⽤yum⽅式安装Jenkins,最简单⽅便。
yum的repos中默认是没有Jenkins的,需要先将Jenkins存储库添加到yum repos。
sudo wget -O /pos.po pkg.jenkins.io/po
sudo rpm --import pkg.jenkins.io/redhat-stable/jenkins.io.key
yum安装Jenkins
yum install jenkins
随后就可以看到系统开始⾃动下载安装。
出现提⽰是否下载的时候输⼊y并按回车。
耐⼼等待安装完成。
现在Jenkins已经安装好了,不过启动之前最好稍微修改⼀下配置。默认情况是Jenkins是使⽤Jenkins⽤户启动的,但这个⽤户⽬前系统并没有赋予权限,这⾥我们将启动⽤户修改为root;另外Jenkins默认端⼝是8080,这个跟tomcat的默认端⼝冲突,我们也修改⼀下默认端⼝。
输⼊命令进⼊Jenkins配置⽂件
## Path: Development/Jenkins
## Description: Jenkins Automation Server
## Type: string
## Default: "/var/lib/jenkins"
## ServiceRestart: jenkins
#
# Directory where Jenkins store its configuration and working
# files (checkouts, build reports, artifacts, ...).
#
JENKINS_HOME="/var/lib/jenkins"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Java executable to run Jenkins
# When left empty, we'll try to find the suitable Java.
#
JENKINS_JAVA_CMD=""
## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
#JENKINS_USER="jenkins"
JENKINS_USER="root" #修改启动⽤户为root
## Type: string
## Default: "false"
## ServiceRestart: jenkins
#
# Whether to skip potentially long-running chown at the
# $JENKINS_HOME location. Do not enable this, "true", unless
# you know what you're doing. See JENKINS-23273.
#
#JENKINS_INSTALL_SKIP_CHOWN="false"
## Type: string
## Default: "-Djava.awt.headless=true"
## Default: "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
## Type: integer(0:65535)
## Default: 8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
#JENKINS_PORT="8080"
JENKINS_PORT="10000" #修改端⼝为10000
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTP requests.
# Default is all interfaces (0.0.0.0).
#
JENKINS_LISTEN_ADDRESS=""
## Type: integer(0:65535)
## Default: ""
## ServiceRestart: jenkins
#
# HTTPS port Jenkins is listening on.
# Default is disabled.
#
JENKINS_HTTPS_PORT=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Path to the keystore in JKS format (as created by the JDK 'keytool').
# Default is disabled.
#
JENKINS_HTTPS_KEYSTORE=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE. # Default is disabled.
#
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTPS requests.
# Default is disabled.
#
JENKINS_HTTPS_LISTEN_ADDRESS=""
## Type: integer(1:9)
## Default: 5
## ServiceRestart: jenkins
## ServiceRestart: jenkins
#
# Debug level for logs -- the higher the value, the more verbose.
# 5 is INFO.
#
JENKINS_DEBUG_LEVEL="5"
## Type: yesno
## Default: no
## ServiceRestart: jenkins
#
# Whether to enable access logging or not.
#
JENKINS_ENABLE_ACCESS_LOG="no"
## Type: integer
## Default: 100
## ServiceRestart: jenkins
#
# Maximum number of HTTP worker threads.
#
JENKINS_HANDLER_MAX="100"
## Type: integer
## Default: 20
## ServiceRestart: jenkins
#
# Maximum number of idle HTTP worker threads.
#
JENKINS_HANDLER_IDLE="20"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Pass arbitrary arguments to Jenkins.
# Full option list: java -jar jenkins.war --help
#
JENKINS_ARGS=""
修改完配置后,保存退出。
好了,现在配置⽂件也修改好了,可以启动Jenkins了。
输⼊启动命令以启动Jenkins服务。
service jenkins start
注意: 启动如果报:
Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See “systemctl status jenkins.service” and 按提⽰输⼊:systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2019-02-16 15:07:46 CST; 39s ago
Docs: man:systemd-sysv-generator(8)
Process: 16856 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Feb 16 15:07:46 localhost.localdomain systemd[1]: Starting LSB: Jenkins
Feb 16 15:07:46 localhost.localdomain runuser[16861]: pam_unix(runuser:session): session opened for user r 0
Feb 16 15:07:46 localhost.localdomain jenkins[16856]: Starting Jenkins bash: /usr/bin/java: No such Feb 16 15:07:46 localhost.localdomain jenkins[16856]: [FAILED]
Feb 16 15:07:46 localhost.localdomain systemd[1]: jenkins.service: control process exited, code=exited status=1 Feb 16 15:07:46 localhost.localdomain systemd[1]: Failed to start LSB: Jenkins Automation Server.
Feb 16 15:07:46 localhost.localdomain systemd[1]: Unit jenkins.service entered failed state.
Feb 16 15:07:46 localhost.localdomain systemd[1]: jenkins.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决办法
意思就是没有到java⽂件,需要⾃⼰把java⽂件地址复制过去
修改/etc/init.d/jenkins⽂件
# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
# see www.nabble/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html 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/bin/java
"
然后再执⾏ 启动命令
出现OK表⽰Jenkins启动成功。
在浏览器输⼊ip:10000进⼊Jenkins登录页⾯。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论