首页 > 其他 > 详细

jenkins本质

时间:2015-11-19 18:26:50      阅读:410      评论:0      收藏:0      [点我收藏+]

Jenkins简介

Jenkins是Java编写的开源的持续集成工具。在与Oracle发生争执后从Hudson项目复制而成。
Jenkins提供了软件开发的持续集成服务。它是运行在Servlet容器(例如Apache Tomcat)的服务器。它支持软件配置管理(SCM)工具(包括AccuRev SCM、CVS、Subversion、Git、Perforce、Clearcase和RTC等),可以执行基于Apache Ant和Apache Maven的项目,以及任意的Shell脚本和Windows批处理命令。Jenkins的主要开发者是Kohsuke Kawaguchi。Jenkins是在MIT许可证下发布的自由软件。

可以通过各种手段触发构建。例如提交给版本控制系统时被触发,也可以通过类似Cron的机制调度,也可以在其他的构建已经完成时,还可以通过特定的URL进行请求。类似的软件有Buildbot、Tox等,另外python中的Django-Jenkins也有一定知名度。
下面是python中使用较多的jenkins相关库:

https://pypi.python.org/pypi/jenkinsapi A Python API for accessing resources on a Jenkins continuous-integration server. 使用最多的python jenkins库。
月下载:6万多
文档:https://github.com/salimfadhley/jenkinsapi
安装:pip install jenkinsapi
用法:

>>> import jenkinsapi
>>> from jenkinsapi.jenkins import Jenkins
>>> J = Jenkins(http://localhost:8080)
>>> J.version
1.542
>>> J.keys() # Jenkins objects appear to be dict-like, mapping keys (job-names) to
[foo, test_jenkinsapi]
>>> J[test_jenkinsapi]
<jenkinsapi.job.Job test_jenkinsapi>
>>> J[test_jenkinsapi].get_last_good_build()
<jenkinsapi.build.Build test_jenkinsapi #77>


https://pypi.python.org/pypi/jenkins-job-builder Manage Jenkins jobs with YAML
月下载:1万多
文档:http://python-jenkins.readthedocs.org/en/latest/

https://pypi.python.org/pypi/python-jenkins Python bindings for the remote Jenkins API
月下载:3万多
文档:http://python-jenkins.readthedocs.org/en/latest/

https://pypi.python.org/pypi/jenkins-autojobs Scripts for automatically creating Jenkins jobs from SCM branches
月下载:2千多
文档:http://jenkins-autojobs.readthedocs.org/en/latest/

https://pypi.python.org/pypi/jenkins-job-builder-naginator Automatically reschedule a build after a build failure.
文档:jenkins-job-builder-naginator.readthedocs.org
月下载:5千多

https://pypi.python.org/pypi/django-jenkins Plug and play continuous integration with django and jenkins
文档:jenkins-job-builder-naginator.readthedocs.org
月下载:2万多

https://pypi.python.org/pypi/autojenkins Jenkins Remote Control Library
月下载:2千多
文档:http://pythonhosted.org/autojenkins/

另外通过python plugin: https://wiki.jenkins-ci.org/display/JENKINS/Python+Plugin可以直接执行python代码。

 

jenkins常见的使用流程如下:

技术分享

技术分享

Jenkins有千余插件,详细列表参见:https://wiki.jenkins-ci.org/display/JENKINS/Plugins。插件教程参见:https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial。插件下载:https://updates.jenkins-ci.org/download/plugins/。

Jenkins安装



进入https://jenkins-ci.org/,在右侧的Native packages下面选择对应的操作系统,这里以Centos为例。点击Centos链接,进入http://pkg.jenkins-ci.org/redhat/。网页的黑底部分即jenkins的安装方法。

技术分享

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
yum install jenkins

通过“ps afx | grep jenkins.war | grep -v grep“查看jenkins.war相关的进程是否启动,如果没有启动,执行"service jenkins start", 现在在浏览器通过“http://localhost:8080“即可访问jenkins。

更多资料参见:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions
注意jenkins当前版本(1.638)要求java 1.7以上的版本。且不能使用centos默认的openjdk,到http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html下载对应的Linux rpm包安装。

 

快速入门

 这里我们添加一个git项目。

“ Manage Jenkins" -> "Manage Plugins" -> "Available", 输入 github :

技术分享

注意上面步骤输入github之后,不要按回车或者搜索框,jenkins会自动搜索。选中上面2个,点击" Click the che Download now and install after restart", 然后重启 Jenkins。

创建Freestyle project:

技术分享

在"Source Code Management"中配置Git:

技术分享

在“Add build step"中选“ Invoke Ant “

技术分享

执行编译:

技术分享

查看控制台输出:

技术分享

 

查看Workspace页面:

技术分享

 大功告成!

 

https://wiki.centos.org/HowTos/Subversion

 

jenkins本质

原文:http://www.cnblogs.com/pythontesting/p/4970808.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!