Tomcat部署脚本返回405 [英] Tomcat deploy script returns 405
问题描述
我正在设置Jenkins,以学习如何在tomcat中实现maven项目的自动部署。
I am setting up Jenkins to learn how to implement the automated deployment of a maven project in tomcat.
tomcat-users.xml具有定义的角色和用户名,感兴趣的人
tomcat-users.xml has the roles and username defined, the ones of interest
<role rolename="manager-script"/>
<user username="jenkins" password="jenkins" roles="manager-script"/>
我已经设置了web.xml以允许使用PUT方法
I have set up web.xml to allow the PUT method
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
,甚至尝试设置管理器应用程序以允许对 /使用PUT方法文本/ *
模式
and even tried to setup the manager application to allow the PUT method for /text/*
pattern
<security-constraint>
<web-resource-collection>
<web-resource-name>Text Manager interface (for scripts)</web-resource-name>
<url-pattern>/text/*</url-pattern>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>manager-script</role-name>
</auth-constraint>
</security-constraint>
但是当我从命令行请求管理器部署脚本时,得到405响应。
But when I request the manager deploy script from the command line I get a 405 response.
curl -u jenkins:jenkins -F filedata=target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"
输出:
<!doctype html><html lang="es"><head><title>Estado HTTP 405 ÔÇô Method Not Allowed</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>Estado HTTP 405 ÔÇô Method Not Allowed</h1><hr class="line" /><p><b>Tipo</b> Informe de estado</p><p><b>mensaje</b> El Metodo HTTP POST no est├í soportado por esta URL</p><p><b>descripci├│n</b> El m├®todo HTTP especificado no est├í permitido para el recurso requerido.</p><hr class="line" /><h3>Apache Tomcat/8.5.42</h3></body></html>
这是HTML响应,表示该路由不支持HTTP POST方法。
which is an HTML response saying the HTTP POST method is not supported for that route.
我使用-F filedata = target / **。war,因为如果在Windows下使用-T选项,则无法打开war文件
I am using -F filedata=target/**.war because if I use -T option under windows the war file can't be opened
curl -v -u jenkins:jenkins -T target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"
输出:
curl:无法打开'target / * * .war'!
output: curl: Can't open 'target/**.war'!
似乎请求带有filedata选项的Tomcat是POST方法,这是不允许的。我如何确保已为经理应用程序启用POST动词?
And seems request Tomcat with filedata option is a POST method which it is not allowed. How can I ensure the POST verb is enabled for manager application?
推荐答案
我在多个版本中具有相同的版本(8.5.x)环境。
I have the same version (8.5.x) in several environments.
我只是按照以下配置在xml tomcat文件中添加权限和用户:
I just add permissions and user in xml tomcat files following these configurations:
https://stackoverflow.com/a/40722537/3957754
然后我能够
不必修改web.xml或管理器。
It was no necessary to modify the web.xml or the manager.
也请检查此链接以查看如何向Tomcat部署战争并获得状态:
Also check this link to review how deploy wars to the tomcat and get the status:
https://stackoverflow.com/a/54292858/3957754
这篇关于Tomcat部署脚本返回405的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!