CentOS7下yum安装Jenkins

Posted qastudy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7下yum安装Jenkins相关的知识,希望对你有一定的参考价值。

Jenkins官网最新稳定版:
https://pkg.jenkins.io/redhat-stable/

1.下载依赖

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

2.导入秘钥

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

3.安装

yum install jenkins #等待安装时间较长,约25min

技术图片

jenkins安装完毕

4.启动前检查是否已安装jdk

java   #显示java参数即证明已安装jdk

5.查找jenkins安装路径

rpm -ql jenkins

技术图片

jenkins安装路径

jenkins相关目录释义:
(1)/usr/lib/jenkins/:jenkins安装目录,war包会放在这里。
( 2 ) /etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。
(3)/var/lib/jenkins/:默认的JENKINS_HOME。
(4)/var/log/jenkins/jenkins.log:jenkins日志文件。

6.配置jenkins
(1)查找jenkins端口

  1.  
    vim /etc/sysconfig/jenkins
  2.  
    set ignorecase
  3.  
    /jenkins_port 回车

技术图片

查找到jenkins端口为8080

(2)查看其他端口占用情况

netstat -ntlp

技术图片

显示已被占用端口

被占用端口与jenkins端口8080无冲突,即可进入下一步启动jenkins

(3)启动jenkins

java -jar /usr/lib/jenkins/jenkins.war --httpPort=8080

(4)修改jenkins端口
若默认8080端口未被占用,可不修改
若端口已被占用,则修改端口为其他端口,并将对应端口开放

  1.  
    #端口改为8899
  2.  
    java -jar /usr/lib/jenkins/jenkins.war --ajp13Port=-1 --httpPort=8899
  1.  
    #启动
  2.  
    java -jar /usr/lib/jenkins/jenkins.war --httpPort=8899

技术图片

启动完成

(5)验证jenkins能否打开
在宿主机浏览器输入http://IP:Port
我这里输入:http://192.168.114.128:8080
(修改端口后输入:http://192.168.114.128:8899)

技术图片

进入jenkins解密界面

 

cat /var/lib/jenkins/secrets/initialAdminPassword

技术图片

获取密码

=>获取密码=>输入密码=>继续
=>安装插件=>retry几次可安装成功
=>注册账号 (记录好账号密码)
=>开始使用Jenkins

技术图片

getting started

ERROR: Linux / Centos:

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

Solution : sudo vi /etc/init.d/jenkins

Add your own java path:

/opt/oracle/product/java/jdk1.8.0_45/bin/java

sudo service jenkins start

sudo service jenkins status

sudo service jenkins stop

方法二:

先导入仓库

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

安装

yum install jenkins

 

启动

安装JDK后,Jenkins无法启动,需要修改vi /etc/rc.d/init.d/jenkins, 查找,输入/java, 添加新的jre路径 

# Search usable Java. We do this because various reports indicated

# that /usr/bin/java may not always point to Java >= 1.6

# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html

candidates="

/etc/alternatives/java

/usr/lib/jvm/java-1.6.0/bin/java

/usr/lib/jvm/jre-1.6.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-1.8.0/bin/java

/usr/lib/jvm/jre-1.8.0/bin/java

/usr/bin/java

/data/java/jdk1.8.0_101/bin/java

"

启动命令:

 systemctl daemon-reload

systemctl enable jenkins

systemctl start jenkins

 

以上是关于CentOS7下yum安装Jenkins的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7下安装MySQL5.7安装与配置(YUM)

centos7下使用yum安装mysql

CentOS7下yum方式安装nginx

CentOS7下yum安装mysql5.6

centos7下使用yum安装mysql

centOS7下安装GUI图形界面