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

jenkins下載:http://pkg.jenkins-ci.org/redhat/html

下載rpm包到本地java

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

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%]

 

自動安裝完成以後: bash

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

/etc/sysconfig/jenkins       配置文件字體

/var/lib/jenkins/        默認的JENKINS_HOME目錄ui

/var/log/jenkins/jenkins.log    Jenkins日誌文件
 
 安裝完成以後啓動jenkinsthis

啓動命令:spa

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

相關文章
相關標籤/搜索