设为首页 收藏本站
查看: 990|回复: 0

[经验分享] (基于Jenkins + SVN + Ant + Weblogic Server的)应用程序自动(/一键)部署的设想

[复制链接]

尚未签到

发表于 2018-1-7 12:29:28 | 显示全部楼层 |阅读模式
  一直想实现自动部署,这里说的自动部署,是指点击一个按钮(或定时执行),让计算机将最新的应用程序发布到相应的环境(UAT或PRD)中。
  自动部署的意义
  自动部署能省去繁琐的人工发布步骤;如配置得当,发布的执行稳定性(成功率)会比较高。
  这样主要有几点意义:


  • 避免繁琐的人工发布。在开发阶段,User总比我们着急,希望快些看到新开发完成的模块,并进行适当的UAT测试。这就可能要求我们完成一个模块的开发和测试后,及时发布到UAT环境中。这时,如果我们配置好定时自动部署。这将避免了繁琐工作,事半功倍。
  • 严谨。如果发布的流程比较复杂,发布过程由人工操作不可避免地会产生粗心的失误。而使用计算机帮忙调度发布的各个动作,如果配置正确,那么失误的可能性将大大降低,除非当初假设的环境参数发生改变。
  我们开发中常用的软件组合为:Java + SVN(版本控制工具) + Ant(编译打包工具) + Weblogic(Web Server)。
  所以我也是以这一套组合为设想,再加上自动部署工具Jenkins。
  大家用的工具不尽相同,但工具间的使用或遵循的规范类似,所以切换应该是可行的。比如现在使用的Web Server是Weblogic,需要切换成Tomcat或Jboss,应该问题不大(但本人没试过- - !)。
  以前做过上述的设想,但一直卡在Weblogic的更新问题上:如何使用脚本让Weblogic更新我们的应用程序。
  最近仔细看了Weblogic文档,发现调用weblogic.Deployer能很好地满足我的需求。
  发布的思路
  那么,自动部署的思路是,使用Jenkins作为任务的总调度师


  • Jenkins首先调用SVN更新代码。
  • Jenkins再调用Ant将工程打成war。并拷贝到指定目录,这里的指定目录指Web Server读取源文件的目录(这个过程可由Ant的build.xml完成,也可由一个单独的脚本完成)。
  • Jenkins再调用一个写好的脚本触发Web Server更新应用程序。比如,使用的是Weblogic,那么这个脚本中就可以使用weblogic.Deployer更新应用程序。
  如何更新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  


Call Redeploy App  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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-432544-1-1.html 上篇帖子: Jenkins小菜初次使用小记 下篇帖子: jenkins 命令行 CLI jenkins-cli.jar
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表