0

I am setting up Jenkins to learn how to implement the automated deployment of a maven project in tomcat.

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

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>      

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>

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"

This is the output:

<!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>

which is an HTML response saying the HTTP POST method is not supported for that route.

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"

output: curl: Can't open 'target/**.war'!

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?

1 Answers1

0

I have the same version (8.5.x) in several environments.

I just add permissions and user in xml tomcat files following these configurations:

https://stackoverflow.com/a/40722537/3957754

Then I was able to deploy war files from anywhere.

It was no necessary to modify the web.xml or the manager.

Also check this link to review how deploy wars to the tomcat and get the status:

https://stackoverflow.com/a/54292858/3957754

JRichardsz
  • 14,356
  • 6
  • 59
  • 94
  • Hi, I am under a windows system and the -T war doesn't work, I need to use -F filepath option and then I get the 405 response. No idea how to fix it. Any help welcome. – Dave Operand Jun 29 '19 at 23:38
  • Could you try with soapui or postman and a fresh tomcat ? 405 means: method not allowed. So I think your tomcat is buggy due to your modifications. As I told you, you just need add users and permissions, anything else. Try to use postman to perform a post or put request to http://$TOMCAT_HOST:$TOMCAT_PORT/manager/text/deploy?path=/$CONTEX_NAME&update=true in order to validate if tomcat configurations are OK before curl tests. – JRichardsz Jun 30 '19 at 01:25
  • I still get the same, the same as if I run curl with -v option, the method is not allowed (405). I am trying to figure out how to allow this verb on tomcat for manager application, however the issue I have I understand it is strange since I have not found any reference to allowing http verbs in tomcat. – Dave Operand Jun 30 '19 at 08:44