jenkins的安裝與配置

來源:互聯網
上載者:User

標籤:jenkins phing

Jenkins是一款Java平台的開源持續整合(Continuous Integration,CI)引擎。它易於安裝,配置簡單,豐富的外掛程式支援,高度的可擴充性,強大的分布式構建能力都讓它在眾多的CI引擎中脫穎而出。首頁:http://jenkins-ci.org/ 

一.安裝jenkins

  1. 準備java環境

    #yum install -y java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64

  2. 安裝jenkins

    安裝jenkins的方法有三種:

    (1)war包方式,可登陸https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins網站下載jenkins.war。將其直接部署到servlet容器,然後啟動容器,在瀏覽器的URL地址欄中輸入http://localhost:8080/jenkins/就可以訪問了。


    (2)下載jenkins.war,然後運行java -jar jenkins.war。該進程會在前台執行,然後在瀏覽器的 URL地址欄中輸入http://localhost:8080/jenkins/就可以訪問了。


    (3)在linux平台下,使用yum進行安裝。這裡我們使用第三種方式進行安裝。

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

     #rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

     #yum install jenkins

  3. 啟動jenkins

    #service jenkins start





二.安裝外掛程式

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/41/9C/wKioL1PWHXDhk-XZAAJlB-e_rPA619.jpg" title="1.jpg" alt="wKioL1PWHXDhk-XZAAJlB-e_rPA619.jpg" />進入頁面後,點擊“可選外掛程式”。需要安裝的外掛程式如下:

GIT plugin, GitHub plugin, Phing plugin, SSH pluin, Hudson SCP publisher plugin。


三.使用pear在伺服器端安裝phing

  登陸http://pear.php.net/go-pear.phar下載最新的go-pear。

  #php go-pear.phar

  #pear install --alldeps phing/phing


四.環境配置

   在“系統管理”—>系統設定中設定Jenkins的相關參數。主要是設定Git和GitHub外掛程式的參數,在Git下的Path to executable一欄中添加原生git.exe的路徑(該路徑可以通過which git命令擷取)。

    在Git plugin下的添加本地Git的user.name和user.email的資訊。

    在Publish over SSH中配置如下參數:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/41/9D/wKiom1PWIk3QUFQKAAF0Z7WRnrM973.jpg" title="2.jpg" alt="wKiom1PWIk3QUFQKAAF0Z7WRnrM973.jpg" />

site目錄是線上伺服器的網頁目錄,絕對路徑為/data/site。


五.構建項目

   點擊“建立”,輸入Item名稱,選擇“構建一個自由式饒舌的軟體項目”,點擊“OK”。系統將進入“任務配置”介面。


六.配置構建方法

   在GitHub project中輸入git地址。

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/41/A0/wKioL1PWJVnzbq0_AAA-8VhoEBs653.jpg" title="3.jpg" alt="wKioL1PWJVnzbq0_AAA-8VhoEBs653.jpg" />

 

在“源碼管理->Git”下的Repository URL輸入Repository的Git地址。

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/41/A0/wKiom1PWJYDwBGiKAACLzYZdp6M731.jpg" title="4.jpg" alt="wKiom1PWJYDwBGiKAACLzYZdp6M731.jpg" /> 

在“構建觸發器”中選擇以下兩項,這兩項的作用分別是當GitHub有版本更新時觸發Jenkins進行構建和定期檢查版本庫是否有更新,如果有更新則觸發Jenkins進行構建。這裡的定期檢查文法和contab的格式一樣。


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/41/A1/wKioL1PWJ5TwPYqoAACa83Tkav0036.jpg" title="5.jpg" alt="wKioL1PWJ5TwPYqoAACa83Tkav0036.jpg" />


在構建下的“Invoke Phing targets”下要輸入target的名稱和xml檔案的存放位置。

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/41/A0/wKiom1PWJy2yTlFMAADPNCard9k864.jpg" title="6.jpg" alt="wKiom1PWJy2yTlFMAADPNCard9k864.jpg" />

在構建下的“Invoke Phing targets”下的“Execute shell”中輸入要執行的shell命令。

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/41/A5/wKiom1PWLzahEVu9AACioppaqVQ052.jpg" title="7.jpg" alt="wKiom1PWLzahEVu9AACioppaqVQ052.jpg" />在“構建後操作”中填寫如下資訊:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/41/A5/wKiom1PWL4PxwEM7AAH2PO86PJs170.jpg" title="8.jpg" alt="wKiom1PWL4PxwEM7AAH2PO86PJs170.jpg" />此時配置完成,這時我們來檢測。在本地倉庫將代碼push到遠程倉庫。然後點擊“立即構建”後,線上上伺服器就可以看到我們的代碼。

本文出自 “營運工作筆記” 部落格,請務必保留此出處http://yyyummy.blog.51cto.com/8842100/1531671

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.