久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Jenkins(二) 安裝,、新建Jobs與刪除及SVN配置

 看見就非常 2012-09-18

官網(wǎng)首頁就提供了windows版本的Jenkins安裝包,。可以自己下載一個用于學(xué)習(xí),。安裝后自動打開http://localhost:8080,,就可以看見Jenkins的界面。

要運(yùn)行Jenkins的其它配置:

1,,Jenkins是java程序,,因此需要安裝JDK。

2,,同時運(yùn)行job需要提供repository,也就是存放Jenkins定期poll源代碼的地方,??梢匀ithub免費(fèi)注冊一個。

3,如果想在Jenkins中使用ant,,maven等,,則還需要單獨(dú)安裝。但不是必須的,。


啟動Jenkins

Jenkins天生支持unix-like system,。

  • 直接運(yùn)行

好吧,Jenkins是一個java程序,,所以要運(yùn)行它,,只需要:

$ java -jar jenkins.war

我們也可以使用nohup命令,讓Jenkins在后臺運(yùn)行,。

之后打開URL http://myServer:8080 就可以方便的操作Jenkins了

官網(wǎng)給了一個sh的例子,,用于啟動Jenkins??梢詤⒖家幌?。

  • 在Servlet container中運(yùn)行

Alternatively, if you have a servlet container that supports Servlet 2.4/JSP 2.0, such as Glassfish v2, Tomcat 5 (or any later versions), then you can run them as services, and deployjenkins.war as you would any other war file.

For example,
you could simply place the jenkins.war file in Tomcat’s webapps directory.  此時使用的URL默認(rèn)就變成:

http://localhost:8080/jenkins


同時Jenkins提供一些默認(rèn)不會啟動的特殊的功能,參考下面的link來enable它們,。

https://wiki./display/JENKINS/Features+controlled+by+system+properties


Jenkins的目錄結(jié)構(gòu)

和CruiseControler一樣,,Jenkins需要一個目錄來存儲相關(guān)文件:JENKINS_HOME。默認(rèn)為 ~/.jenkins,。即為user的home目錄下的一個隱藏目錄,。我們也可以更改JENKINS_HOME,指向我們希望的地方,。

(注意因為是隱藏目錄,,所以需要使用ls -al 才能看到)

JENKINS_HOME
  +- config.xml     (jenkins root configuration)
  +- *.xml          (other site-wide configuration files)
  +- userContent    (files in this directory will be served under your http://server/userContent/)
  +- fingerprints   (stores fingerprint records)
  +- plugins        (stores plugins)
  +- jobs
     +- [JOBNAME]      (sub directory for each job)
         +- config.xml     (job configuration file)
         +- workspace      (working directory for the version control system)
         +- latest         (symbolic link to the last successful build)
         +- builds
             +- [BUILD_ID]     (for each build)
                 +- build.xml      (build result summary)
                 +- log            (log file)
                 +- changelog.xml  (change log)

如果有權(quán)限管理,則在HOME目錄下還會有users目錄,。

從目錄結(jié)構(gòu)來看,,和CruiseController非常相似。其中config.xml是Jenkins重要的配置文件,。我們都知道Jenkins用于monitor多個build,,而jobs這個目錄無疑就是存儲每個build相關(guān)信息的地方。

總的來說,,Jenkins目錄結(jié)構(gòu)非常直白,,簡潔。


備份和恢復(fù)

備份和恢復(fù)非常簡單,,就是簡單的copy Jenkins的目錄就好了:

All the settings, build logs, artifact archives are stored under the JENKINS_HOME directory. Simply archive this directory to make a back up. Similarly, restoring the data is just replacing the contents of the JENKINS_HOME directory from a back up.


移動/拷貝/重命名 job

由于每個jobs都有自己單獨(dú)的目錄,,我們可以很容易的:

    1,move a job from one installation of Jenkins to another by simply copying the corresponding job directory.
   ,2,,make a copy of an existing job by making a clone of a job directory by a different name.
    3,,rename an existing job by renaming a directory.

修改后執(zhí)行下面的命令刷新:

http://[jenkins-server]/[command] 

在這里[command]可以是:exit 退出,,restart 重啟, reload 重載,。


創(chuàng)建一個Project

因為Jenkins可以用于運(yùn)行各種CI,,測試,批處理任務(wù)等等,,所以在Jenkins中將這些任務(wù)統(tǒng)稱為“free-style software project”.

Jenkins也提供了其他類型的jobs,,例如:

1,如果項目是Maven,,Jenkins還提供了一種僅用于Maven Project的job,。但其實free-style software projec仍然可以用于創(chuàng)建Maven項目,只不過這種更適合Maven項目,,結(jié)合的更好而已,。

2,也可以創(chuàng)建一個"Monitor an external job“用于監(jiān)控外部進(jìn)程,。

3,,或者一個Matrix project,也就是multi-configuration project,。

我不確定是否僅有這4種job,,也許使用插件可以創(chuàng)建更多類型的job,大家自己看資料吧,。


下面是如何創(chuàng)建一個最常見的“free-style software project"的過程:


ok確定


這之前有很多描述性的工作可以自己選擇,,配置svn要Subersion,在Repository URL中輸入svn地址,,點(diǎn)擊enter credential


這里輸入svn用戶名和密碼即可,,在已建項目中可以點(diǎn)擊Configure


自動運(yùn)行Build

觸發(fā)一個build有三種方式:

  • Builds in Jenkins can be triggered periodically (on a schedule, specified in configuration) 這里定義schedule的語法是unix常見的cron語法。
  • Or when source changes in the project have been detected

可以設(shè)置Jenkins定時檢查SVN是否發(fā)生了變化,,也可以手動檢查:http://YOURHOST/jenkins/job/PROJECTNAME/pollong,。也可以設(shè)置Jenkins為post-commit,這個方式尤其適用于那些檢查是否代碼改變會花費(fèi)很長時間的情況,。

  • Or they can be automatically triggered by requesting the URL:

http://YOURHOST/jenkins/job/PROJECTNAME/build


Distributed builds

Jenkins supports the "master/slave" mode, where the workload of building projects are delegated to multiple "slave" nodes, allowing single Jenkins installation to host a large number of projects, or provide different environments needed for builds/tests.

在現(xiàn)實中需要使用distributed builds情況很多,,例如:一個web application的build,需要分別驗證firefox和IE的行為,,那么就需要到windows機(jī)器上運(yùn)行IE,。

或因為性能問題,將build分布到多個slave節(jié)點(diǎn)去,。


到Jenkins的管理界面,,就可以方便的添加節(jié)點(diǎn)。配置節(jié)點(diǎn)時,,需要提供節(jié)點(diǎn)所在的機(jī)器,,登陸用戶名密碼,,使用的目錄等,。

但是slave并不需要再安裝Jenkins,。jenkins會自動啟用slave agent,將build需要tools考到遠(yuǎn)程機(jī)器上,。

需要注意的是:the build results and artifacts will always end up on the master server. 因此不需要跑到各個節(jié)點(diǎn)去查看build產(chǎn)生的文件,,log等。

其實在slave節(jié)點(diǎn),,會創(chuàng)建一個本地的workspace,,并在運(yùn)行時使用這個workspace。因為畢竟build運(yùn)行在slave節(jié)點(diǎn)上,,所以這個節(jié)點(diǎn)肯定要有運(yùn)行build需要的所有因素,。

總之添加節(jié)點(diǎn)并遠(yuǎn)程運(yùn)行build真是太方便了~


添加節(jié)點(diǎn)后,在master Jenkins home目錄下會出現(xiàn)關(guān)于該節(jié)點(diǎn)的配置文件,。

Jenkins將自動決定在哪個節(jié)點(diǎn)上運(yùn)行build,,根據(jù)下列策略:

Some slaves are faster, while others are slow. Some slaves are closer (network wise) to a master, others are far away. So doing a good build distribution is a challenge. Currently, Jenkins employs the following strategy:

  1. If a project is configured to stick to one computer, that's always honored.
  2. Jenkins tries to build a project on the same computer that it was previously built.
  3. Jenkins tries to move long builds to slaves, because the amount of network interaction between a master and a slave tends to be logarithmic to the duration of a build (IOW, even if project A takes twice as long to build as project B, it won't require double network transfer.) So this strategy reduces the network overhead.

Jenkins通過運(yùn)行slave agents來完成分布式build。最常見的情況是:slave agent運(yùn)行在各個slave 節(jié)點(diǎn),。master通過SSH遠(yuǎn)程啟動/停止slave agent,,進(jìn)而控制各個節(jié)點(diǎn)的行為。

一共有下列4種方式啟動slave agent:

The master starts the slave agents via ssh
Starting the slave agent manually using Java Web Start
Installing the slave agent as a Window service
Starting the slave agent directly from the command line on the slave machine from the command line

需要注意的是這4種方式適用于不同的情況,,例如slave節(jié)點(diǎn)在防火墻后,,導(dǎo)致master無法通過SSH啟停slave agent。此時只能用后三種方式,,但是往往有一些弊端,,比如master無法自動停止/重啟 slave agent.

一旦添加node成功,你就可以在job中指定這個job在哪個node運(yùn)行:

Restrict where this project can be run (如果不指定則由Jenkins自行決定,,即可以在slave節(jié)點(diǎn)運(yùn)行,,也可以在master節(jié)點(diǎn)運(yùn)行,甚至在一次build中就可以自行來回切換),。


配置Jenkins,,讓它收集更多的log

https://wiki./display/JENKINS/Logging


在流行持續(xù)集成的今天,在各個環(huán)境:alpha,beta和production 都部署了唯一的Jenkins服務(wù)器,。

Jenkins服務(wù)器統(tǒng)一負(fù)責(zé)該環(huán)境內(nèi)所有組件的持續(xù)集成,。也就是說,一個Jenkins服務(wù)器會有很多個build,。所以有時會用到上面提到的”Monitor an external job“,。

但不是Distributed Builds。


同時由于Jenkins會進(jìn)入每個環(huán)境,,包括production,,因此會使用auto deployment的方式,,自動完成Jenkins在各個環(huán)境的部署。


用戶管理

毫無疑問Jenkins中需要有用戶管理的功能,,因為除開發(fā)人員外,,有多種角色的人需要查看build的結(jié)果。

在Jenkins中的系統(tǒng)管理中,,可以設(shè)置“任何用戶可以做任何事” 或 “登錄用戶可以做任何事”,。

因此前一個選項意味著,任何瀏覽JenkinsURL的用戶都可以修改Jenkins,?;蛑挥械卿浻脩舨拍茏鲂薷摹?/p>

Jenkins中的用戶劃分為兩類:可登錄用戶和不可登錄用戶,。

1,,只要是修改過repository,即對build產(chǎn)生過影響的用戶,,都會被Jenkins記錄在本地的database中,。這類用戶可以在Jenkins界面->查看用戶中瀏覽。

但這類用戶不是正式的Jenkins用戶,,也不能登錄Jenkins,。這類用戶的權(quán)限由上面說的系統(tǒng)管理中的配置決定。通常只有查看build的權(quán)限,,沒有修改權(quán)限,。

2,只有在Jenkins中明確注冊的用戶,,才能夠登錄Jenkins,,并且有權(quán)限控制。同時注冊過的用戶,,在JENKINS_HOME目錄下的users目錄下,,都有一個單獨(dú)的目錄來存儲相關(guān)信息。


Jenkins Script Console

Jenkins提供了一個script console Groovy script which allows to run arbitrary scripts on the Jenkins server or on slave nodes. This feature can be accessed from the "manage Jenkins" link,。

也可以通過URL直接訪問:http://myserver:8080/hudson/script

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多