代码改变世界

Jenkins自动构建 和docker安装

2016-03-07 12:16  youxin  阅读(1255)  评论(0编辑  收藏  举报

Jenkins is an award-winning, cross-platform, continuous integration and continuous delivery application that increases your productivity. Use Jenkins to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by providing powerful ways to define your build pipelines and integrating with a large number of testing and deployment technologies.

http://jenkins-ci.org/

Hudson是Jenkins的前身,是基于Java开发的一种持续集成工具。

 

Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括:
1、持续的软件版本发布/测试项目。
2、监控外部调用执行的工作。
 
首先保证系统中已经安装了jdk,最好是jdk1.5以上。
第一种启动方法,切换到jenkins.war存放的目录,输入如下命令:
$ java -jar jenkins.war
然后在浏览器中(推荐用火狐)输入localhost:8080,localhost可以是本机的ip,也可以是计算机名。就可以打开jenkins
第二种方法是用tomcat打开
解压tomcat到某个目录,如/usr/local,进入tomcat下的/bin目录,启动tomcat.
将jenkins.war文件放入tomcat下的webapps目录下,启动jenkins时,会自动在webapps目录下建立jenkins目录,所以在地址栏上需要输入的地址于上一种方法有点不一样。
 

 系统设置

在已运行的Jenkins主页中,点击左侧的系统管理—>系统设置进入如下界面:

 

 

使用
 
1.新建一个job
2.
 
(丢弃旧的构建:http://www.blogjava.net/qileilove/archive/2014/02/08/409616.html
http://www.2cto.com/os/201502/377054.html
 
 
 
 
  • 配置svn
 
 
 
  • 配置构建触发条件
 
 
 
  • 配置构建触发执行动作,将执行生成报告脚本

自动运行Build

触发一个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是否发生了变化,也可以手动检查: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

 

 
 
  • 设置构建后操作
 
 
 
  • 构建效果
 

 

 
 
http://www.ibm.com/developerworks/cn/java/j-lo-jenkins/
http://blog.csdn.net/littlechang/article/details/8642149
http://blog.csdn.net/pingnanlee/article/details/18962207
 

jenkins下搭建c++持续集成环境

 

docker安装jenkins:

Jenkins安装包有两种,一种是LTS,一种是Weekly。LTS是稳定版,Weekly每周会更新一次,一般使用LTS就行了,

docker pull jenkins/jenkins:lts