Java 如何使用 jenkins 创建 .war 文件进行部署

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24400581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 11:59:57  来源:igfitidea点击:

How to create .war file using jenkins for deployment

javaantjenkinsjenkins-pluginswar

提问by Kamal Gadepalli

I started working on Jenkins for continuous integration. My java project is build successfully but am not able to find .war file for deployment. If I manually keep the myproject.war file inside workspace auto deployment is happening in tomcat7.

我开始使用 Jenkins 进行持续集成。我的 java 项目已成功构建,但无法找到用于部署的 .war 文件。如果我手动将 myproject.war 文件保存在工作区中,则在 tomcat7 中会自动部署。

Now my question: is Jenkins able to create .war or not (if any extra plugins are needed please let me know), or if i need to add any build.xml file where can i keep this file.

现在我的问题是:Jenkins 是否能够创建 .war(如果需要任何额外的插件,请告诉我),或者如果我需要添加任何 build.xml 文件,我可以在哪里保存这个文件。

Thanks in advance.

提前致谢。

采纳答案by Kamal Gadepalli

Finally i find the solution, Jenkins is not having a feature like auto creating .war file. so we have to create build.xml (ANT) for creating .war file. Keep this file in your project and check-in into the repository. And map the build.xml location in Jenkins configuration page. When the build is happen through Jenkins it will take the code from repository build it and stores in workspace in Jenkins folder along with .war file. You can do auto deploy this .war file into your tomcat using Jenkins.

最后我找到了解决方案,Jenkins 没有像自动创建 .war 文件这样的功能。所以我们必须创建 build.xml (ANT) 来创建 .war 文件。将此文件保留在您的项目中并签入到存储库中。并在 Jenkins 配置页面中映射 build.xml 位置。当构建通过 Jenkins 发生时,它将从存储库中获取代码构建它并与 .war 文件一起存储在 Jenkins 文件夹中的工作区中。您可以使用 Jenkins 将此 .war 文件自动部署到您的 tomcat 中。