问题描述
我正在编写一个 shell 脚本来使用 tomcat 管理器自动部署/取消部署.
I'm writing a shell script to auto deploy/undeploy using the tomcat manager.
按照 http://tomcat.apache 上的说明进行操作.org/tomcat-6.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely,我使用 curl 进行部署
Following the instructions on http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely, I use curl for my deployment
curl --anyauth -u username:pwd -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy
我收到回复说此 URL 不支持 HTTP 方法 POST.
And I get the response saying HTTP method POST is not supported by this URL.
所以我将我的 curl 改为使用 -G
So I change my curl to be a get using -G
curl --anyauth -u username:pwd -G -d path=/something -d war=file:target/someWar.war https://someurl.com/manager/deploy
我收到 FAIL 的响应 - 无法在上下文路径/something 部署应用程序,它似乎在服务器上本地而不是我的机器上查找文件.有一些插件可以进行远程部署,而无需 scp 文件,所以我想知道我错过了什么.
I get a response of FAIL - Failed to deploy application at context path /something and it seems to be looking for the file locally on the server instead of my machine. There are pluings which do remote deploy without having to scp the file over so I'm wondering what I'm missing.
我目前没有想法(我在 tomcat 管理器配置页面上没有看到任何其他选项).
I'm currently out of ideas (I don't see any other option on the tomcat manager configuration page).
推荐答案
这种方式在 Tomcat 6 上对我有用(参见 jevelopers answer for tomcat 7):
This way is working for me on Tomcat 6 (See jevelopers answer for tomcat 7):
curl --upload-file <path to warfile> "http://<tomcat username>:<tomcat password>@<hostname>:<port>/manager/deploy?path=/<context>&update=true"
示例:
curl --upload-file targetdebug.war "http://tomcat:tomcat@localhost:8088/manager/deploy?path=/debug&update=true"
非常简单.输出是这样的:
Very easy peasy. Output is like this:
OK - Undeployed application at context path /debug
OK - Deployed application at context path /debug
这篇关于Tomcat 管理器远程部署脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!