标签:read 构建 ips dso figure default 打包 ready 一个
下载hudson ,安装部署http://hudson-ci.org/
将下载的hudson-3.3.3.war放到tomcat的webapps目录下并启动tomcat,输入地址访问
点击Install安装Hudson核心插件
安装过程比较慢
完成后点击Finish
配置安全管理 点击 “系统管理”--》“Configure Security”
如下
点击注册填写如下信息注册一个系统管理员账户
添加插件 点击 “系统管理”--》“插件管理” 安装需要的插件,当插件安装好后需要重启一次Hudson才能生效。
Hudson全局配置信息
点击保存到如下界面
-----------------------------------------------------------------------------------------------------------------
eclipse中的项目
----------------------------------------------------------------------------------------------------------------------
新建任务和任务配置
hudson任务表示一个持续集成的项目,任务配置包括项目版本控制分支、集成任务触发器(何时触发项目集成)
进入“新建任务”, 输入任务名称,并选择“构建一个自由风格的软件项目”点击下一步。
其中有几点我们要留意一下,这也关系到我们是否能成功实现自动打包与部署。
在
"Source Code Management"
下面,我们选择“Subversion”:这意味着我们的Hudson将Subversion提供的地址作为我们的基础文件,后期也是基于此进行打包。 其中"Repository
URL"填写SVN项目地址(保证Hudson从SVN从检出的源码直接放到.hudson\jobs\当前任务\workspace目录下。即:从项目的根目录(不包括根目录)检出也就是pom.xml所在目录),其余保持默认就行即可。
第二个需要设置的为轮询策略,用来告诉Hudson用哪一种策略来执行这一个任务。
常用的为Poll SCM,通过Unix中的任务高度工具所使用的配置方式来进行配置。
以空格为分隔符,从左到右依次代表着分、时、日、月、星期
*号代替着任意时间,如* * * * *,再如*/10 * * * * 代表着每隔10分钟任务执行一次,*/10代表着能被10整除的意思。
第三步,用来设置我们的打包方式。
在Build下面,我们"Add build step"中,我们可以选择一项打包方式来将我们在第一步设置的源码进行处理。
因为我们的项目是用的Maven,所以我在此选择Invoke
Maven。那么这样Hudson就会调用Maven的打包命令,将我们的源码进行打包。选择maven的版本,然后输入maven的命令。(需要注意的是,在Hudson的服务器上面需要安装Maven,并在Hudson的系统配置中进行配置)
那么剩下的,就是需要将我们打包好的项目部署到tomcat(远程部署)中去,那么应如何做呢?
在这里我们需要用到Hudson的一个名为 over SSH的插件(没安装的请自行到Hudson的插件管理中去下),勾选“ Send build artifacts over SSH”
项目的over SSH 详细配置如下
点击Save保存进入如下界面
通过以上的配置,我们基本上就告诉了Hudson这个任务的一些基本信息了,包括调度时间("build trigger"),需管理的源码(Soruce Code Management),打包方式(Build),部署(Post-build Actions)。
点击”构建“图标进行一次构建,点击Console控制台图标查看构建日志
Started by user admin Cleaning the workspace because project is configured to clean the workspace before each build. Checking out a fresh workspace because there‘s no workspace at C:\Users\Administrator\.hudson\jobs\crm_job\workspace Cleaning workspace C:\Users\Administrator\.hudson\jobs\crm_job\workspace Checking out https://d1osxkijfdv9p4f:8443/svn/repo/crm/trunk revision: 2016-12-4 23:16:18 depth:infinity ignoreExternals: false
A crm A crm\.classpath A crm\.project A crm\src A crm\src\test A crm\src\test\java A crm\src\main A crm\src\main\java A crm\src\main\resources A crm\src\main\webapp A crm\src\main\webapp\index.jsp A crm\src\main\webapp\WEB-INF A crm\src\main\webapp\WEB-INF\web.xml A crm\pom.xml A crm\.settings A crm\.settings\org.eclipse.jdt.core.prefs A crm\.settings\org.eclipse.m2e.core.prefs A crm\.settings\org.eclipse.wst.jsdt.ui.superType.name A crm\.settings\org.eclipse.wst.jsdt.ui.superType.container A crm\.settings\org.eclipse.wst.common.project.facet.core.xml A crm\.settings\.jsdtscope A crm\.settings\org.eclipse.wst.validation.prefs A crm\.settings\org.eclipse.wst.common.component
At revision 24 no change for https://d1osxkijfdv9p4f:8443/svn/repo/crm/trunk since the previous build [workspace] $ "D:\Program Files\apache-maven-3.2.5\bin\mvn.bat" -f crm/pom.xml clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building crm Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ crm ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ crm ---
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ crm ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ crm ---
[INFO] skip non existing resourceDirectory C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ crm ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ crm ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ crm ---
[INFO] Packaging webapp
[INFO] Assembling webapp [crm] in [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\src\main\webapp]
[INFO] Webapp assembled in [36 msecs]
[INFO] Building war: C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.974 s
[INFO] Finished at: 2016-12-04T23:16:29+08:00
[INFO] Final Memory: 10M/228M
[INFO] ------------------------------------------------------------------------
SSH: Connecting from host [D1OSXKIJFDV9P4F] SSH: Connecting with configuration [CentOS远程部署项目服务器] ...
SSH: EXEC: STDOUT/STDERR from command [## 远程服务器上的jdk环境 export JAVA_HOME=/usr/local/jdk1.7.0_55 export JRE_HOME=/usr/local/jdk1.7.0_55/jre ## 停止远程服务器上的 tomcat 休眠几秒后删除项目再重启 /usr/local/apache-tomcat-7.0.61/bin/shutdown.sh sleep 3 rm -rf /usr/local/apache-tomcat-7.0.61/webapps/crm /usr/local/apache-tomcat-7.0.61/bin/startup.sh] ...
Tomcat started. SSH: EXEC: completed after 6,006 ms SSH: Disconnecting configuration [CentOS远程部署项目服务器] ... SSH: Transferred 1 file(s) Finished: SUCCESS
来看看.hudson任务的workspace下
进入crm目录
进入target目录
运行看看效果
修改修改index.jsp后提交修改到svn
点击构建项目按钮,刷新浏览器
———————————————————————————————————————————————————————————
其他方式部署(注意:热部署必须先启动tomcat,否则会报拒绝连接!)
使用 Deploy war/ear to a container 的tomcat容器热部署项目(无需重启tomcat容器)
参数说明:
WAR/EAR files:要上传到服务器的war包
Context path:上下文路径(服务器上的tomcat的webapps目录)
Container:容器类型,如Jetty,Tomcat
Manager user name:tomcat管理员控制台用户名
Manager password:tomcat管理员控制台密码
Tomcat URL:访问路径 http://192.168.42.128:8081
设置tomcat控制管理员密码,点击Manager App
提示信息
配置tomcat的可操作权限.
在tomcat的安装目录下,修改conf / tomcat-user.xml文件,在<tomcat-users> 节点下面增加如下配置(多个角色用“,”隔开):
<role rolename="manager-gui" /> <role rolename="manager-script" /> <user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/> |
vim conf/tomcat-users.xml
保存,后重启tomcat,配置Deploy war/ear to a container
点击构建,输出日志:
Started by user admin
Cleaning the workspace because project is configured to clean the workspace before each build.
Checking out a fresh workspace because there‘s no workspace at C:\Users\Administrator\.hudson\jobs\crm_job\workspace
Cleaning workspace C:\Users\Administrator\.hudson\jobs\crm_job\workspace
Checking out https://d1osxkijfdv9p4f:8443/svn/repo/crm/trunk revision: 2016-12-8 1:20:50 depth:infinity ignoreExternals: false
A crm
A crm\.classpath
A crm\.project
A crm\src
A crm\src\test
A crm\src\test\java
A crm\src\main
A crm\src\main\java
A crm\src\main\resources
A crm\src\main\webapp
A crm\src\main\webapp\index.jsp
A crm\src\main\webapp\WEB-INF
A crm\src\main\webapp\WEB-INF\web.xml
A crm\pom.xml
A crm\.settings
A crm\.settings\org.eclipse.jdt.core.prefs
A crm\.settings\org.eclipse.m2e.core.prefs
A crm\.settings\org.eclipse.wst.jsdt.ui.superType.name
A crm\.settings\org.eclipse.wst.jsdt.ui.superType.container
A crm\.settings\org.eclipse.wst.common.project.facet.core.xml
A crm\.settings\.jsdtscope
A crm\.settings\org.eclipse.wst.validation.prefs
A crm\.settings\org.eclipse.wst.common.component
At revision 27
no change for https://d1osxkijfdv9p4f:8443/svn/repo/crm/trunk since the previous build
[workspace] $ "D:\Program Files\apache-maven-3.2.5\bin\mvn.bat" -f crm/pom.xml clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building crm Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ crm ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ crm ---
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ crm ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ crm ---
[INFO] skip non existing resourceDirectory C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ crm ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ crm ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ crm ---
[INFO] Packaging webapp
[INFO] Assembling webapp [crm] in [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\src\main\webapp]
[INFO] Webapp assembled in [55 msecs]
[INFO] Building war: C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.972 s
[INFO] Finished at: 2016-12-08T01:20:55+08:00
[INFO] Final Memory: 11M/244M
[INFO] ------------------------------------------------------------------------
Deploying C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war to container Tomcat 7.x Remote
Redeploying [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war]
Undeploying [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war]
Deploying [C:\Users\Administrator\.hudson\jobs\crm_job\workspace\crm\target\crm.war]
Finished: SUCCESS
tomcat目录
刷新浏览器
修改index.jsp
使用Hudson重新构建后刷新浏览器
Hudson + SVN + Maven 持续集成实现自动化编译、打包、部署(over SSH 和 Deploy war/ear to a container 两种部署方式)
标签:read 构建 ips dso figure default 打包 ready 一个
原文地址:http://www.cnblogs.com/YingYue/p/7677760.html