【问题标题】:tomcat 405 error when deploying from jenkins to tomcat从jenkins部署到tomcat时出现tomcat 405错误
【发布时间】:2020-05-12 17:49:28
【问题描述】:

我正在学习 jenkins,我一直很难使用参数将 jenkins 部署到 tomcat,尤其是在 windows 机器上运行的 jenkins。 这个问题与之前在 stackoverflow 上提出的问题几乎相同,但我不认为答案是匹配的,因为它是如此广泛。问题已解释here

我的tomcat用户权限设置如下

<role rolename="tomcat"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="manager" password="tomcat" roles="tomcat,manager-gui"/>
  <user username="jenkins" password="jenkins" roles="manager-script"/>

我正在尝试在带有 curl 的 Windows 10 上使用以下 curl 命令进行部署

curl -u %tcuser%:%tcpass% -F filedata=target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"

我在 jenkins 中遇到以下错误

C:\WINDOWS\system32\config\systemprofile\AppData\Local\Jenkins.[*******]\workspace\devops01>curl -u [*******]:[*******] -F filedata=target/**.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true" 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   908  100   752  100   156    752    156  0:00:01 --:--:--  0:00:01  7264
<!doctype html><html lang="en"><head><title>HTTP Status 405 – Method Not Allowed</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 405 – Method Not Allowed</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> HTTP method POST is not supported by this URL</p><p><b>Description</b> The method received in the request-line is known by the origin server but not supported by the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.54</h3></body></html>
C:\WINDOWS\system32\config\systemprofile\AppData\Local\Jenkins.[*******]\workspace\devops01>exit 0 

有人可以帮我吗?

【问题讨论】:

  • 有人可以帮忙吗?相信很多人都遇到过类似的问题。谢谢。

标签: maven jenkins tomcat


【解决方案1】:

curl -F 发出一个 POST 请求(请参阅the manual page)。然而,Tomcat 管理器的 deploy 命令只接受 GET 或 PUT 请求——这就是你得到 Method Not Allowed Error (HTTP Status 405) 的原因。

如果你想deploy your webapp by remote upload,你必须使用-T命令行选项运行curl,例如:

curl -u %tcuser%:%tcpass% -T devops.war "http://localhost:8080/manager/text/deploy?path=/devops&update=true"

这使得 curl 使用 PUT 方法(而不是 POST)。

如果您只想部署到 localhost,您还可以让 Tomcat 管理器从本地路径 as described here 部署 WAR 文件。无论哪种方式,您都必须提供 WAR 文件的确切路径。 target/**.war 中的通配符不起作用。

编辑:有些人报告了在 Windows 上使用 curl -T 上传文件的问题。如果您也遇到这些问题,那么this workaround 可能会帮助您。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 2013-03-03
    • 2011-03-23
    • 1970-01-01
    • 2015-12-29
    • 1970-01-01
    相关资源
    最近更新 更多