标签:style blog http io ar color os 使用 sp
一直想实现自动部署,这里说的自动部署,是指点击一个按钮(或定时执行),让计算机将最新的应用程序发布到相应的环境(UAT或PRD)中。
自动部署的意义
自动部署能省去繁琐的人工发布步骤;如配置得当,发布的执行稳定性(成功率)会比较高。
这样主要有几点意义:
我们开发中常用的软件组合为:Java + SVN(版本控制工具) + Ant(编译打包工具) + Weblogic(Web Server)。
所以我也是以这一套组合为设想,再加上自动部署工具Jenkins。
大家用的工具不尽相同,但工具间的使用或遵循的规范类似,所以切换应该是可行的。比如现在使用的Web Server是Weblogic,需要切换成Tomcat或Jboss,应该问题不大(但本人没试过- - !)。
以前做过上述的设想,但一直卡在Weblogic的更新问题上:如何使用脚本让Weblogic更新我们的应用程序。
最近仔细看了Weblogic文档,发现调用weblogic.Deployer能很好地满足我的需求。
发布的思路
那么,自动部署的思路是,使用Jenkins作为任务的总调度师
如何更新Weblogic部署的应用程序
weblogic.Deployer是class,所以执行时需附上对应classpath,JAR在$WLS_HOME/server/lib/weblogic.jar。
我使用redeploy的参数实现更新应用程序:
java -cp $WLS_HOME/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://xx.xx.xx.xx:7001 -username weblogicusername -password weblogicpassword -name appname -redeploy
PS,附上weblogic.Deployer的帮助信息:
Usage: java weblogic.Deployer [options] [action] [Deployment units(s)]
where options include:
-help Print the standard usage message.
-version Print version information.
-adminurl <<protocol>://<server>:<port>> [option] Administration
server URL: default t3://localhost:7001
-username <username> [option] user name
-password <password> [option] password for the user
-userconfigfile <userconfigfile> [option] The user config file
contains the user security credentials; it
is administered by the weblogic.Admin tool
-userkeyfile <keyConfigFile> [option] The users key file; it is
administered by the weblogic.Admin tool.
-distribute [action] Distribute application to the
targets.
-start [action] Makes an already distributed
application available on a target.
-stop [action] Makes an application unavailable on
targets.
-redeploy [action] Replace a running application
partially or entirely.
-undeploy [action] Take an application out of service.
-deploy [action] Make an application available for
service.
-update [action] Update an application configuration
in place.
-examples [option] Displays example usage of this tool.
-name <application name> [option] Defaults to the basename of the
deployment file or directory.
-targets <<target(s)>> [option] A comma separated list of targets
for the current operation. If not specified,
all configured targets are used. For a new
application, the default target is the
administration server.
-plan <Deployment plan path> [option] Specifies location of
deployment plan
-library [option] Indicates that the unit being
deployed is a library. This option is
required when the application is a library.
-advanced Print advanced usage options.
The optional trailing arguments are deployment units and may
represent the archive being deployed, the name of a previously
deployed application or a list of files for a partial redeploy operation.
(基于Jenkins + SVN + Ant + Weblogic Server的)应用程序自动(/一键)部署的设想
标签:style blog http io ar color os 使用 sp
原文地址:http://www.cnblogs.com/nick-huang/p/3866800.html