首页 > 代码库 > 在centos中使用rpm安装包安装jenkins

在centos中使用rpm安装包安装jenkins

jenkins下载:http://pkg.jenkins-ci.org/redhat/

下载rpm包到本地

在linux下使用rpm包安装命令:

sudo rpm -ih jenkins-1.562-1.1.noarch.rpm
[root@bogon Desktop]# sudo rpm -ih jenkins-2.9-1.1.noarch.rpm 
warning: jenkins-2.9-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
########################################### [100%]
########################################### [100%]

 

自动安装完成之后: 

/usr/lib/jenkins/jenkins.war    WAR包 

/etc/sysconfig/jenkins       配置文件

/var/lib/jenkins/        默认的JENKINS_HOME目录

/var/log/jenkins/jenkins.log    Jenkins日志文件
 
 安装完成之后启动jenkins

启动命令:

sudo service jenkins start
[root@bogon jenkins]# sudo service jenkins start
Starting Jenkins bash: /usr/bin/java: No such file or directory
                                                           [FAILED]

会报这个错误,这是由于没有配置java环境,有两种方法可以解决:

1. 安装jdk环境

  先检查一下java虚拟机有没有安装,如果没有就安装

java --version
//如果没有,则安装
yum search java-
//找到高版本的java安装包
sudo yum install java-1.7.0-openjdk.i686

2.在jenkins配置文件中配置

  需要“vi /etc/init.d/jenkins”,把java路径加上,如下:

# 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
/usr/java/jdk1.7.0_79/bin/java
"
for candidate in $candidates
do
  [ -x "$JENKINS_JAVA_CMD" ] && break
  JENKINS_JAVA_CMD="$candidate"
done

JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"

  上述配置文件中红色字体的内容是我配置自己的jdk路径

 

由于我的系统中的java是自己解压安装的,所以我采用了第二种方式

再次启动jenkins:

[root@bogon jenkins]# sudo service jenkins start
Starting Jenkins                                           [  OK  ]

启动正常,可以访问:http://localhost:8080

技术分享


 

在centos中使用rpm安装包安装jenkins