Jenkins部署项目到Tomcat8,项目名为ROOT出现问题?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

Jenkins部署项目到Tomcat8,项目名为ROOT出现问题?报错

爱吃鱼的程序员 2020-06-08 13:08:43 364

最近引入了Jenkins自动化部署,前面拉代码、打包都没问题,唯独部署出问题。

为了访问方便(能从根目录访问网站),我们是将项目打包为ROOT.war丢到tomcat的webapps下的。

已经配置好了tomcat的相关用户deploy并给予了权限。

这里是我们的测试服务器以远程部署的方式给自己部署,也就是输入了自己的网址和端口号。

经测试,如果项目名字不是ROOT.war(比如起名abc.war),经过Jenkins构建并通过Deploy to container Plugin插件部署后,再次构建是可以覆盖前面的abc.war

但ROOT.war不能被覆盖,如果webapps下面有ROOT.war,直接构建部署会报错Error writing request body to server:

Deploying /srv/codes/eshifu_boss/target/ROOT.war to container Tomcat 7.x Remote
  [/srv/codes/eshifu_boss/target/ROOT.war] is not deployed. Doing a fresh deployment.
  Deploying [/srv/codes/eshifu_boss/target/ROOT.war]
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to deploy [/srv/codes/eshifu_boss/target/ROOT.war]
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:111)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:997)
	at hudson.FilePath.act(FilePath.java:975)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
	at hudson.model.Run.execute(Run.java:1760)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:405)
Caused by: java.io.IOException: Error writing request body to server
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3479)
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3462)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.pipe(TomcatManager.java:647)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:538)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)
	... 17 more
java.io.IOException: Error writing request body to server
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3479)
	at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3462)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.pipe(TomcatManager.java:647)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:538)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:997)
	at hudson.FilePath.act(FilePath.java:975)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1072)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
	at hudson.model.Run.execute(Run.java:1760)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:405)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

目前解决方案是:写一个本地脚本,在部署前将原有的ROOT.war和解压后的ROOT文件夹删掉,这样才能顺利部署。

因为后期打算用测试服务器以远程部署到线上服务器,可这样就没办法通过执行本地脚本清空原有项目,这个疑问还是要解决的。

恳求有Jenkins+Tomcat(+Git+Maven)部署经验的大牛指点

jenkins项目 部署项目项目tomcat tomcat问题部署项目 项目部署问题报错 报错oom
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-08 13:08:56

    不要沉啊,求大神解救

    你要实现热部署?
    #BUILD_ID=DONT_KILL_MEsudokill-9`netstat-tlnp|grep端口|awk'{print$7}'|awk-F'/''{print$1}'` cp/opt/tomcat/webapps/ROOT.war/opt/backwar/washcar_$(date-d"today"+"%Y%m%d_%H%M%S").warsh/opt/tomcat/bin/shutdown.shcp/var/lib/jenkins/workspace/项目/target/ROOT.war/opt/tomcat/webapps/ROOT.warsh/opt/tomcat/bin/startup.sh

    在 Runonlyifbuildsucceeds里使用

    引用来自“铂金蛋蛋”的评论

    #BUILD_ID=DONT_KILL_MEsudokill-9`netstat-tlnp|grep端口|awk'{print$7}'|awk-F'/''{print$1}'` cp/opt/tomcat/webapps/ROOT.war/opt/backwar/washcar_$(date-d"today"+"%Y%m%d_%H%M%S").warsh/opt/tomcat/bin/shutdown.shcp/var/lib/jenkins/workspace/项目/target/ROOT.war/opt/tomcat/webapps/ROOT.warsh/opt/tomcat/bin/startup.sh

    在 Runonlyifbuildsucceeds里使用

    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

相似问题
最新问题
推荐课程