简体   繁体   English

从Git自动将Grails / Java Web应用程序部署到Tomcat7

[英]Automated deployment of Grails/Java web application to Tomcat7 from Git

I saw automated deployment of heroku as in this link. 我在这个链接中看到了heroku的自动部署。 And it was amazing as it allowed me to deploy the grails web application directly from git repository to tomcat. 它令人惊讶,因为它允许我将grails web应用程序直接从git存储库部署到tomcat。

Now I was wondering that can I use a similar thing to deploy my grails web application directly from my VCS(Git) to tomcat 7 if I am using other hosting provider (or to my personal dedicated server). 现在我想知道如果我使用其他托管服务提供商(或我的个人专用服务器),我可以使用类似的东西将我的Grails Web应用程序直接从我的VCS(Git)部署到tomcat 7。

In other words, I want to setup automated loop for my grails web application. 换句话说,我想为我的grails Web应用程序设置自动循环。 And preferable is there a generic way for any other java web application built using web frameworks like spring/strutts etc. 对于使用像spring / strutts等web框架构建的任何其他java Web应用程序,最好有一种通用的方法。

Short answer: Yes you can. 简短回答:是的,你可以。 But you'll need to do it manually. 但你需要手动完成。

Heroku uses the concept of post-receive hooks and buildpacks which automatically deploy the application when code is pushed to the master branch of your version control. Heroku使用post-receive hooks和buildpacks的概念,当代码被推送到版本控制的master分支时,它会自动部署应用程序。 In case of GitHub, you can use their webhooks to configure post-receive hooks that can automatically create a WAR file and deploy automatically to your QA or production server, for example. 在GitHub的情况下,您可以使用他们的webhook来配置可以自动创建WAR文件并自动部署到QA或生产服务器的post-receive挂钩。

You can follow GitHub's guide to setting up your first webhook ( https://developer.github.com/webhooks/creating/ ). 您可以按照GitHub的指南来设置您的第一个webhook( https://developer.github.com/webhooks/creating/ )。 Basically, whenever you push data to a GitHub repo, it will send the data to a URL of your choice (also known as a webhook). 基本上,每当您将数据推送到GitHub仓库时,它都会将数据发送到您选择的URL(也称为webhook)。 You can have a listener running on this address which will process the data and run a custom script which in your case will deploy your Java application. 您可以在此地址上运行一个侦听器,该侦听器将处理数据并运行自定义脚本,在您的情况下将部署Java应用程序。 They are using a Ruby file but you can use any language you prefer, even a bash script. 他们使用的是Ruby文件,但你可以使用你喜欢的任何语言,甚至是bash脚本。

You can also see a sample payload sent by GitHub https://gist.github.com/gjtorikian/5171861 您还可以看到GitHub发送的示例有效负载https://gist.github.com/gjtorikian/5171861

The post-receive hook is a very common concept and is available in almost every version control system out there. 后接收挂钩是一个非常常见的概念,几乎在每个版本控制系统中都可用。 For your own dedicated server or your own hosted version control, you'll need to implement this from the scratch. 对于您自己的专用服务器或您自己的托管版本控件,您需要从头开始实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM