简体   繁体   English

如何从Nexus自动部署战争到Tomcat?

[英]How can I automatically deploy a war from Nexus to Tomcat?

How can I automatically deploy a war from Nexus to Tomcat? 如何从Nexus自动部署战争到Tomcat?

I have a maven web project which gets built and deployed (both SNAPSHOT and release versions) on Nexus successfully. 我有一个maven web项目,可以在Nexus上成功构建和部署(SNAPSHOT和发布版本)。 I would like to know if there is feature/plugin in Nexus where it picks the released war and deploys on remote Tomcat automatically? 我想知道Nexus中是否有功能/插件,它会选择已发布的战争并自动部署在远程Tomcat上?

I know that you can deploy the war to remote Tomcat using maven-tomcat-plugin but would like to know if there is an alternative solution. 我知道您可以使用maven-tomcat-plugin将战争部署到远程Tomcat,但是想知道是否有替代解决方案。

Please guide. 请指导。

Typically you'd use a CI tool like Jenkins to run the Maven build that publishes your War file into Nexus. 通常,您使用像Jenkins这样的CI工具来运行将War文件发布到Nexus的Maven构建。 Nexus would then be used by whatever tool you're using to push the War onto the target tomcat environment: 然后,Nexus将被您用于将战争推送到目标tomcat环境的任何工具使用:

在此输入图像描述

There are lots and lots of options. 有很多很多选择。

Jenkins post build SSH script Jenkins发布了SSH脚本

Run a post-build SSH task from Jenkins that does something like this on the target tomcat server: 从Jenkins运行构建后的SSH任务,在目标tomcat服务器上执行类似的操作:

curl "http://myrepo/nexus/service/local/artifact/maven/redirect?r=releases&g=myorg&a=myapp&v=1.1&e=war" \
     -o /usr/local/share/tomcat7/webapps/myapp.war
service tomcat7 restart

Rundeck Rundeck

My preference is to use Rundeck for deployments, because it has a Nexus plugin , providing convenient drop-down menus of available releases. 我的偏好是使用Rundeck进行部署,因为它有一个Nexus插件 ,提供方便的可用版本下拉菜单。

There is also a Rundeck plugin for Jenkins that can be used to orchestrate a CI process with Jenkins performing the build, hand-over to Rundeck for deployment, followed by a Jenkins call-back to run the integration tests. 还有一个用于Jenkins的Rundeck插件 ,可用于协调CI进程,Jenkins执行构建,移交到Rundeck进行部署,然后进行Jenkins回调以运行集成测试。

Chef 厨师

I also use chef which can be used to automatically deploy software in a pull fashion. 我还使用厨师,可用于以拉动方式自动部署软件。

The artifact cookbook has direct support for Nexus, whereas the application_java cookbook uses a more generic "pull from a URL" approach that also works well. 神器食谱直接支持Nexus,而application_java cookbook使用更通用的“从URL拉取”方法也很有效。

.. .. .. ..

The list goes on, so I hope this helps. 名单还在继续,所以我希望这会有所帮助。

我们使用UrbanCode进行部署自动化,从Artifactory / Nexus检索战争并部署到目标服务器。

I used the Nexus Rest-API, these endpoints downloads the artifact to Jenkins workspace. 我使用了Nexus Rest-API,这些端点将工件下载到Jenkins工作区。

In order to deploy Snapshot & Release to Tomcat we can create a Jenkins parameterized job and pass the parameters to the REST endpoint, also to deploy to a server like Tomact "Deploy WAR/EAR" Jenkins plugin will help. 为了将Snapshot和Release部署到Tomcat,我们可以创建一个Jenkins参数化作业并将参数传递给REST端点,也可以部署到像Tomact“Deploy WAR / EAR”这样的服务器,Jenkins插件会有所帮助。

詹金斯参数化工作

We can parameterize the endpoint and use as part of "Build" step along with "Execute Shell script" option for the build. 我们可以参数化端点并将其用作“构建”步骤的一部分以及构建的“执行Shell脚本”选项。

wget --user=${UserName} --password=${Password} "http://192.168.49.131:8080/nexus/service/local/artifact/maven/redirect?r=releases&g=${GroupId}&a=${ArtifactId}&v=${Version}&e=${TypeOfArtifact}" --content-disposition

Actual endpoints to Nexus looks something like below. Nexus的实际端点如下所示。

wget --user=admin --password=admin123 "http://localhost:8080/nexus/service/local/artifact/maven/redirect?r=snapshots&g=org.codezarvis.artifactory&a=hushly&v=0.0.1-SNAPSHOT&e=jar" --content-disposition

wget --user=admin --password=admin123 "http://localhost:8080/nexus/service/local/artifact/maven/redirect?r=releases&g=org.codezarvis.artifactory&a=hushly&v=0.0.5&e=jar" --content-disposition

Thanks 谢谢
-Sudarshan -Sudarshan

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

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