0

I'm learning jenkins and I've been having hard time with jenkins deploying to tomcat using parameters, especially jenkins running on windows machine. The issue is pretty much the same as the one asked before on stackoverflow, but I don't see the answer as a match as it's so broad. The issue was explained here

I have tomcat users permissions set as bellow

<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"/>

and I'm trying deploy using the following curl command on windows 10 with curl

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

I'm getting the following error in 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 

Can someone please help me ?

NoMaster
  • 29
  • 6

1 Answers1

0

curl -F issues a POST request (see the manual page). The Tomcat Manager's deploy command, however, only accepts GET or PUT requests -- which is why you got the Method Not Allowed Error (HTTP Status 405).

If you want to deploy your webapp by remote upload, you have to run curl with the -T command line option, e.g.:

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

This makes curl use the PUT method (instead of POST).

If you only want to deploy to localhost, you can also have Tomcat Manager deploy a WAR file from a local path as described here. Either way, you'll have to give an exact path to your WAR file. Wildcards as in target/**.war won't work.

EDIT: Some people have reported problems uploading files using curl -T on Windows. If you face these problems, too, then this workaround might help you.

uwesinha
  • 46
  • 6