国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

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

官網(wǎng)首頁就提供了windows版本的Jenkins安裝包??梢宰约合螺d一個用于學習。安裝后自動打開http://localhost:8080,就可以看見Jenkins的界面。

要運行Jenkins的其它配置:

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

2,同時運行job需要提供repository,也就是存放Jenkins定期poll源代碼的地方。可以去github免費注冊一個。

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


啟動Jenkins

Jenkins天生支持unix-like system。

  • 直接運行

好吧,Jenkins是一個java程序,所以要運行它,只需要:

$ java -jar jenkins.war

我們也可以使用nohup命令,讓Jenkins在后臺運行。

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

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

  • 在Servlet container中運行

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默認就變成:

http://localhost:8080/jenkins


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

https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties


Jenkins的目錄結構

和CruiseControler一樣,Jenkins需要一個目錄來存儲相關文件:JENKINS_HOME。默認為 ~/.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)

如果有權限管理,則在HOME目錄下還會有users目錄。

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

總的來說,Jenkins目錄結構非常直白,簡潔。


備份和恢復

備份和恢復非常簡單,就是簡單的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都有自己單獨的目錄,我們可以很容易的:

    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可以用于運行各種CI,測試,批處理任務等等,所以在Jenkins中將這些任務統(tǒng)稱為“free-style software project”.

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

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

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

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

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


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


ok確定


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


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


自動運行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

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

  • 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機器上運行IE。

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


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

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

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

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

總之添加節(jié)點并遠程運行build真是太方便了~


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

Jenkins將自動決定在哪個節(jié)點上運行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通過運行slave agents來完成分布式build。最常見的情況是:slave agent運行在各個slave 節(jié)點。master通過SSH遠程啟動/停止slave agent,進而控制各個節(jié)點的行為。

一共有下列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é)點在防火墻后,導致master無法通過SSH啟停slave agent。此時只能用后三種方式,但是往往有一些弊端,比如master無法自動停止/重啟 slave agent.

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

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


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

https://wiki.jenkins-ci.org/display/JENKINS/Logging


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

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

但不是Distributed Builds。


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


用戶管理

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

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

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

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

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

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

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


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

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
git+jenkins在windows機器上新建一個slave節(jié)點
Jenkins 技巧及常用插件
Jenkins & Docker 持續(xù)集成實踐
Jenkins最佳實踐
jenkins主從服務器部署
RFS的web自動化驗收測試——第15講 RF結合Jenkins(下)
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服