为什么 Jenkins 1.598 和 tomcat 8 自动部署不起作用
why Jenkins 1.598 and tomcat 8 auto deployment does not work
我有 Jenkins 1.598。我在 jenkins 中安装了自动部署插件(但它不适用于 tomcat 8,目前还没有更新)。
一切正常!构建完成后,它开始重新部署。但有时我有这样的错误,我不明白它发生的时间和原因。当我重新启动 tomcat 时,一切又恢复正常了!
Deploying C:\jenkins\test\target\tr-gui.war to container Tomcat 7.x Remote
Redeploying [C:\jenkins\test\target\tr-gui.war]
Undeploying [C:\jenkins\test\target\tr-gui.war]
ERROR: Publisher hudson.plugins.deploy.DeployPublisher aborted due to exception
org.codehaus.cargo.container.ContainerException: Failed to undeploy [C:\jenkins\test\target\tr-gui.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:140)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1784)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\servers\tomcat 8\webapps\test]. The continued presence of this file may cause problems.
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
... 17 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\servers\tomcat 8\webapps\tr-gui]. The continued presence of this file may cause problems.
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1784)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model
.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Sending e-mails to: test@mytest.com
Finished: FAILURE
我认为当时您的测试和 tr-gui 应用程序未正确关闭。
这是 Matt Mello 的旧评论(来自 this bug report):
I had the same problem.
It turns out that we had a log4j appender setup in our app to append
to an HTML file in our webapp's directory, and apparently log4j would
not release the file until we properly shutdown the appenders.
Shutting down the app wasn't enough. This might have been due to the
fact that log4j itself is loaded from tomcat instead of from the app?
Not sure.
Anyway, I added code in the servlet destroy method to cleanup the
appenders and this ensured that the file was closed so that tomcat
could delete the directory.
[Don't even get me started on the security issues involved in what we
were doing. That is another topic.]
Note that velocity might also write some logs into your webapp's
directory. I believe I have seen that before, too.
我有 Jenkins 1.598。我在 jenkins 中安装了自动部署插件(但它不适用于 tomcat 8,目前还没有更新)。
一切正常!构建完成后,它开始重新部署。但有时我有这样的错误,我不明白它发生的时间和原因。当我重新启动 tomcat 时,一切又恢复正常了!
Deploying C:\jenkins\test\target\tr-gui.war to container Tomcat 7.x Remote
Redeploying [C:\jenkins\test\target\tr-gui.war]
Undeploying [C:\jenkins\test\target\tr-gui.war]
ERROR: Publisher hudson.plugins.deploy.DeployPublisher aborted due to exception
org.codehaus.cargo.container.ContainerException: Failed to undeploy [C:\jenkins\test\target\tr-gui.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:140)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1784)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\servers\tomcat 8\webapps\test]. The continued presence of this file may cause problems.
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
... 17 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unable to delete [C:\servers\tomcat 8\webapps\tr-gui]. The continued presence of this file may cause problems.
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:480)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.undeploy(TomcatManager.java:420)
at org.codehaus.cargo.container.tomcat.Tomcat7xRemoteDeployer.performUndeploy(Tomcat7xRemoteDeployer.java:62)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.undeploy(AbstractTomcatManagerDeployer.java:130)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:178)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:116)
at hudson.plugins.deploy.CargoContainerAdapter.invoke(CargoContainerAdapter.java:103)
at hudson.FilePath.act(FilePath.java:981)
at hudson.FilePath.act(FilePath.java:959)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
at hudson.tasks.BuildStepMonitor.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1784)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model
.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Sending e-mails to: test@mytest.com
Finished: FAILURE
我认为当时您的测试和 tr-gui 应用程序未正确关闭。
这是 Matt Mello 的旧评论(来自 this bug report):
I had the same problem.
It turns out that we had a log4j appender setup in our app to append to an HTML file in our webapp's directory, and apparently log4j would not release the file until we properly shutdown the appenders. Shutting down the app wasn't enough. This might have been due to the fact that log4j itself is loaded from tomcat instead of from the app? Not sure.
Anyway, I added code in the servlet destroy method to cleanup the appenders and this ensured that the file was closed so that tomcat could delete the directory.
[Don't even get me started on the security issues involved in what we were doing. That is another topic.]
Note that velocity might also write some logs into your webapp's directory. I believe I have seen that before, too.