1、安装Deploy Plugin插件
This plugin takes a war/ear file and deploys that to a running remote application server at the end of a build. The implementation is based on Cargo. The list of currently supported containers include:
Tomcat 4.x/5.x/6.x/7.x
JBoss 3.x/4.x
Glassfish 2.x/3.x
远程部署不包括resin啊!
插件下载地址:
http://ftp-nyc.osuosl.org/pub/jenkins/plugins/deploy/1.9/deploy.hpi
版本:1.9
插件地址:
https://wiki.jenkins-ci.org/display/JENKINS/Deploy+Plugin
登录Jenkins
选择 Jenkins->系统管理->管理插件->高级 上传插件,选择deploy.hpi文件上传,上传完成后需要重新启动Jenkins
在插件管理的已安装标签下,可以看到“Deploy to container Plugin”,证明插件安装成功
2、配置job
build已经完成打war包功能,Deploy Plugin只是负责远程部署
在“构建后操作” 选择“deploy war/era to a container”
输入下面参数:
WAR/EAR files:war包路径
Context path:空白,未填,还没弄清楚用处
Container:下拉菜单,选择容器
Deploy on failure:未勾选,还没弄清楚用处
可参考下图:
部署结果:
部署碰到个问题:
Jenkins控制台没有报任何错误,build也是成功的,但是就是未在远端服务器看到war包,查了资料,原来war包路径错误会导致部署失败,但是不会报错(猜想:因为此时已经build完成了,不属于build的范围,所以不会改变build结果)。
解决问题参考这个网址:
http://stackoverflow.com/questions/9277223/jenkins-auto-deploy-tomcat-7
I was having the same problem, and in my case the (relative) path to the WAR file was incorrect. Apparently if you don’t have it exactly correct (it needs to be relative to the workspace root) then the deploy plugin will silently fail. In my case the path was:
target/whatever.war
Once that was fixed, I ran into a different problem in that the plugin expects to connect to the manager/text version of Tomcat Manager, rather than the manager/html version that I usually configure by default. You’ll need a line in your tomcat-users.xml file like the following:
(This is in addition to the “manager-gui” role you probably already have set up.)
Once those changes were made, the build and deployment worked just fine.