Linux環境安裝Jenkins


安裝環境:

  CenOS 6.4

  JDK_1.6.0_23

 

一、安裝前檢查環境

檢查是否安裝JDK: java --version

 

二、安裝Jenkins

1. 添加Jenkins的源(repository)

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

(rpm --import 簽名文件;wget -O 保存文件)

2.下載Jenkins

wget http://ftp-chi.osuosl.org/pub/jenkins/redhat/jenkins-1.573-1.1.noarch.rpm

3.安裝Jenkins

rpm -ivh jenkins-1.573-1.1.noarch.rpm

安裝完成后,有如下相關目錄:

(3.1)/usr/lib/jenkins/:jenkins安裝目錄,WAR包會放在這里。

$ cd /usr/lib/jenkins
$ ll
-rw-r--r-- 1 root root 52891723 Feb 27 00:13 jenkins.war

(3.2) /etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在這里配置。內容如下:

復制代碼
## Path:        Development/Jenkins
## Description: Configuration for the Jenkins continuous build 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"

## Type:        string
## 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"

## Type:        integer(0:65535)
## Default:     8009
## ServiceRestart: jenkins
#
# Ajp13 Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_AJP_PORT="8009"

## Type:        integer(1:9)
## Default:     5
## 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=""

3.3)/var/lib/jenkins/:默認的JENKINS_HOME。目錄結構如下:

3.4)/var/log/jenkins/jenkins.log:Jenkins日志文件。

 

4. 啟動Jenkins

service jenkins start

有可能出現錯誤:“Starting Jenkins -bash: /usr/bin/java: No such file or directory”。表示找不到Jenkins找不到java。

這時就需要“vi /etc/init.d/jenkins”,把java路徑加上(如下):

64 # Search usable Java. We do this because various reports indicated
65 # that /usr/bin/java may not always point to Java 1.5
66 # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
67 for candidate in /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 .5.0/bin/java /usr/lib/jvm/jre-1.5.0/bin/java  /usr/local/jdk_1.6.0_23/bin/java

68 do
69 [ -x "$JENKINS_JAVA_CMD" ] && break
70 JENKINS_JAVA_CMD="$candidate"
71 done

 

5. 登錄Jenkins

如果沒有特別配置端口,使用http://<ip address>:8080/登錄Jenkins,並進行相關配置(插件安裝、權限配置、View/Job創建等等)。



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM