歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

centos 安裝jenkins

centos 安裝jenkins

centos 安裝jenkins


1.安裝JDK7

1.1 下載JDK7

可能不能直接使用wget下載,可使用迅雷下載

http://download.oracle.com/otn-pub/Java/jdk/7/jdk-7-linux-i586.tar.gz

拷貝到目錄/usr/local

1.2 解壓安裝包

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#tar-zxvfjdk-7-linux-i586.tar.gz

1.3修改環境變量

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#vi/etc/profile

添加下面幾行

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. exportJAVA_HOME=/usr/local/jdk1.7.0
  2. exportJRE_HOME=/usr/local/jdk1.7.0/jre
  3. exportCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
  4. exportPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

1.4 執行命令

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@bogonopt]#source/etc/profile

這樣環境變量的修改就生效了

1.5 驗證JDK安裝結果

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [[email protected]]#java-version
  2. javaversion"1.7.0"
  3. Java(TM)SERuntimeEnvironment(build1.7.0-b147)
  4. JavaHotSpot(TM)ClientVM(build21.0-b17,mixedmode)
  5. ng:1.0pt;}

2.安裝maven

2.1 下載maven

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#wgethttp://mirrors.cnnic.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

2.2 解壓maven

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#tar-zxvfapache-maven-3.3.9-bin.tar.gz

2.3 配置maven安裝路徑

修改文件/etc/profile,添加下面三行

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. MAVEN_HOME=/usr/local/apache-maven-3.3.9
  2. exportMAVEN_HOME
  3. exportPATH=${PATH}:${MAVEN_HOME}/bin

讓修改生效

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#source/etc/profile

2.4 驗證安裝結果

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#mvn-v
  2. ApacheMaven3.3.9(bb52d8502b132ec0a5a3f4c09453c07478323dc5;2015-11-10T08:41:47-08:00)
  3. Mavenhome:/usr/local/apache-maven-3.3.9
  4. Javaversion:1.7.0,vendor:OracleCorporation
  5. Javahome:/usr/local/jdk1.7.0/jre
  6. Defaultlocale:en_US,platformencoding:UTF-8
  7. OSname:"linux",version:"2.6.32-431.el6.i686",arch:"i386",family:"unix"

3.安裝Jenkins

3.1 下載jenkins

http://211.162.52.227/files/4054000003480AF6/ftp.yz.yamagata-u.ac.jp/pub/misc/jenkins/redhat-stable/jenkins-2.7.3-1.1.noarch.rpm

將安裝包拷貝到目錄/usr/local

3.2.安裝jenkins

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostlocal]#rpm-ivhjenkins-2.7.3-1.1.noarch.rpm

jenkins的安裝目錄是/usr/lib/jenkins,裡面有個WAR包jenkins.war

3.3.修改jenkins配置文件

添加下面一行

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. /usr/local/jdk1.7.0/bin/java

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostjenkins]#vi/etc/sysconfig/jenkins
  2. candidates="
  3. /etc/alternatives/java
  4. /usr/lib/jvm/java-1.6.0/bin/java
  5. /usr/lib/jvm/jre-1.6.0/bin/java
  6. /usr/lib/jvm/java-1.7.0/bin/java
  7. /usr/lib/jvm/jre-1.7.0/bin/java
  8. /usr/lib/jvm/java-1.8.0/bin/java
  9. /usr/lib/jvm/jre-1.8.0/bin/java
  10. /usr/bin/java
  11. /usr/local/jdk1.7.0/bin/java"

3.4 啟動jenkins

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostjenkins]#servicejenkinsstart
  2. StartingJenkins[OK]

3.5 開放端口8080

jenkins的默認端口號是8080,防火牆要開放這個端口,外部才能訪問。

添加下面一行

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. -<spanstyle="font-family:Arial,Helvetica,sans-serif;">AINPUT-mstate--stateNEW-mtcp-ptcp--dport8080-jACCEPT</span>

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostjenkins]#vi/etc/sysconfig/iptables
  2. #Firewallconfigurationwrittenbysystem-config-firewall
  3. #Manualcustomizationofthisfileisnotrecommended.
  4. *filter
  5. :INPUTACCEPT[0:0]
  6. :FORWARDACCEPT[0:0]
  7. :OUTPUTACCEPT[0:0]
  8. -AINPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
  9. -AINPUT-picmp-jACCEPT
  10. -AINPUT-ilo-jACCEPT
  11. -AINPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
  12. -AINPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
  13. <precode_snippet_id="1876506"snippet_file_name="blog_20160911_9_9918486"name="code"class="java">-<spanstyle="font-family:Arial,Helvetica,sans-serif;">AINPUT-mstate--stateNEW-mtcp-ptcp--dport8080-jACCEPT</span>
-A INPUT -jREJECT --reject-with icmp-host-prohibited-A FORWARD -jREJECT --reject-with icmp-host-prohibited

3.6 重啟防火牆

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostjenkins]#serviceiptablesrestart
  2. iptables:SettingchainstopolicyACCEPT:filter[OK]
  3. iptables:Flushingfirewallrules:[OK]
  4. iptables:Unloadingmodules:[OK]
  5. iptables:Applyingfirewallrules:[OK]

3.7 浏覽器訪問jenkins

http://192.168.1.105:8080

進入目錄/var/lib/jenkins/secrets

查看密碼

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostsecrets]#viinitialAdminPassword
  2. 2aa80bb4a1ce4a269996b1b2ba6cefc1
3.8 查看運行日志

[java]view plaincopy在CODE上查看代碼片派生到我的代碼片
  1. [root@localhostjenkins]#more/var/log/jenkins/jenkins.log

http://xxxxxx/Linuxjc/1184815.html TechArticle

Copyright © Linux教程網 All Rights Reserved