CentOS 上 Jenkins 安装
CentOS上Jenkins安装
文章来源:http://www.cnblogs.com/zhangqingsh/archive/2013/03/19/2968998.html
1.添加Jenkins的源(repository):
$sudowget-O/etc/yum.repos.d/jenkins.repohttp://jenkins-ci.org/redhat/jenkins.repo
$sudorpm--importhttp://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
2.安装/检查JDK:
$java--version
$sudoyuminstalljava-1.6.0-openjdk
3.安装Jenkins:
$sudoyuminstalljenkins
安装完成后,有如下相关目录:
(3.1)/usr/lib/jenkins/:jenkins安装目录,WAR包会放在这里。
$cd/usr/lib/jenkins
$ll
-rw-r--r--1rootroot52891723Feb2700:13jenkins.war
(3.2)/etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。内容如下:
复制代码
##Path:Development/Jenkins
##Description:ConfigurationfortheJenkinscontinuousbuildserver
##Type:string
##Default:"/var/lib/jenkins"
##ServiceRestart:jenkins
#
#DirectorywhereJenkinsstoreitsconfigurationandworking
#files(checkouts,buildreports,artifacts,...).
#
JENKINS_HOME="/var/lib/jenkins"
##Type:string
##Default:""
##ServiceRestart:jenkins
#
#JavaexecutabletorunJenkins
#Whenleftempty,we'lltrytofindthesuitableJava.
#
JENKINS_JAVA_CMD=""
##Type:string
##Default:"jenkins"
##ServiceRestart:jenkins
#
#UnixuseraccountthatrunstheJenkinsdaemon
#Becarefulwhenyouchangethis,asyouneedtoupdate
#permissionsof$JENKINS_HOMEand/var/log/jenkins.
#
JENKINS_USER="jenkins"
##Type:string
##Default:"-Djava.awt.headless=true"
##ServiceRestart:jenkins
#
#OptionstopasstojavawhenrunningJenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
##Type:integer(0:65535)
##Default:8080
##ServiceRestart:jenkins
#
#PortJenkinsislisteningon.
#Setto-1todisable
#
JENKINS_PORT="8080"
##Type:integer(0:65535)
##Default:8009
##ServiceRestart:jenkins
#
#Ajp13PortJenkinsislisteningon.
#Setto-1todisable
#
JENKINS_AJP_PORT="8009"
##Type:integer(1:9)
##Default:5
##ServiceRestart:jenkins
#
#Debuglevelforlogs--thehigherthevalue,themoreverbose.
#5isINFO.
#
JENKINS_DEBUG_LEVEL="5"
##Type:yesno
##Default:no
##ServiceRestart:jenkins
#
#Whethertoenableaccessloggingornot.
#
JENKINS_ENABLE_ACCESS_LOG="no"
##Type:integer
##Default:100
##ServiceRestart:jenkins
#
#MaximumnumberofHTTPworkerthreads.
#
JENKINS_HANDLER_MAX="100"
##Type:integer
##Default:20
##ServiceRestart:jenkins
#
#MaximumnumberofidleHTTPworkerthreads.
#
JENKINS_HANDLER_IDLE="20"
##Type:string
##Default:""
##ServiceRestart:jenkins
#
#PassarbitraryargumentstoJenkins.
#Fulloptionlist:java-jarjenkins.war--help
#
JENKINS_ARGS=""
复制代码
(3.3)/var/lib/jenkins/:默认的JENKINS_HOME。目录结构如下:
复制代码
$cd/var/lib/jenkins/
$ls-lst
total216
4-rw-r--r--1jenkinsjenkins0Mar1823:59Fingerprintcleanup.log
4-rw-r--r--1jenkinsjenkins0Mar1818:54Workspaceclean-up.log
8drwxr-xr-x180jenkinsjenkins4096Mar1817:04fingerprints
8-rw-r--r--1jenkinsjenkins1636Mar1816:41config.xml
8-rw-r--r--1jenkinsjenkins903Mar1816:41hudson.maven.MavenModuleSet.xml
8-rw-r--r--1jenkinsjenkins1122Mar1816:41hudson.plugins.sonar.SonarPublisher.xml
8-rw-r--r--1jenkinsjenkins205Mar1816:41hudson.plugins.sonar.SonarRunnerInstallation.xml
8-rw-r--r--1jenkinsjenkins196Mar1816:41hudson.scm.CVSSCM.xml
8-rw-r--r--1jenkinsjenkins692Mar1816:41hudson.scm.SubversionSCM.xml
8-rw-r--r--1jenkinsjenkins145Mar1816:41hudson.tasks.Ant.xml
8-rw-r--r--1jenkinsjenkins187Mar1816:41hudson.tasks.Mailer.xml
8-rw-r--r--1jenkinsjenkins330Mar1816:41hudson.tasks.Maven.xml
8-rw-r--r--1jenkinsjenkins76Mar1816:41hudson.tasks.Shell.xml
8-rw-r--r--1jenkinsjenkins215Mar1816:41hudson.triggers.SCMTrigger.xml
8-rw-r--r--1jenkinsjenkins264Mar1816:41jenkins.model.JenkinsLocationConfiguration.xml
8-rw-r--r--1jenkinsjenkins907Mar1816:29nodeMonitors.xml
8-rw-r--r--1jenkinsjenkins159Mar1816:29hudson.model.UpdateCenter.xml
8-rw-r--r--1jenkinsjenkins46Mar1816:29queue.xml.bak
8drwxr-xr-x2jenkinsjenkins4096Mar1816:24updates
4-rw-r--r--1jenkinsjenkins0Mar1610:27ConnectionActivitymonitoringtoslaves.log
8drwxr-xr-x6jenkinsjenkins4096Mar1318:24workspace
8drwxr-xr-x13jenkinsjenkins4096Mar1317:59jobs
8drwx------2jenkinsjenkins4096Feb2811:16secrets
8-rw-r--r--1jenkinsjenkins165Feb2713:29sonar.xml
8drwxr-xr-x14jenkinsjenkins4096Feb2713:29plugins
8-rw-------1jenkinsjenkins1679Feb2712:12identity.key
8drwxr-xr-x2jenkinsjenkins4096Feb2712:12userContent
8-rw-r--r--1jenkinsjenkins64Feb2712:12secret.key
4-rw-r--r--1jenkinsjenkins0Feb2712:12secret.key.not-so-secret
复制代码
(3.4)/var/log/jenkins/jenkins.log:Jenkins日志文件。
4.启动Jenkins
$sudoservicejenkinsstart
有可能出现错误:“StartingJenkins-bash:/usr/bin/Java:Nosuchfileordirectory”。表示找不到Jenkins找不到java。
这时就需要“vi/etc/init.d/jenkins”,把java路径加上(如下):
复制代码
64#SearchusableJava.Wedothisbecausevariousreportsindicated
65#that/usr/bin/JavamaynotalwayspointtoJava1.5
66#seehttp://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
67forcandidatein/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/opt/app/jdk1.7.0_09/bin/java
68do
69[-x"$JENKINS_JAVA_CMD"]&&break
70JENKINS_JAVA_CMD="$candidate"
71done