Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat manager remote deploy script

Tags:

curl

tomcat

I'm writing a shell script to auto deploy/undeploy using the tomcat manager.

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 

And I get the response saying HTTP method POST is not supported by this URL.

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 

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.

I'm currently out of ideas (I don't see any other option on the tomcat manager configuration page).

like image 449
bluesman Avatar asked Dec 13 '10 19:12

bluesman


People also ask

How do I deploy a WAR manager in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.

What is Tomcat autoDeploy?

The autoDeply attribute on the Host element determines if the web application will be available for access on the internet. To learn how to use the autoDeploy attribute in Apache Tomcat, follow these two steps: Open a text editor session on CATALINA_BASE/conf/server. xml ,e.g., c:/Tomcat8/conf/server. xml .


2 Answers

Providing an update to this question.

Tomcat 7 has changed it's manager API.

Please refer to: Manager commands

Following new URL pattern :

http://{host}:{port}/manager/text/{command}?{parameters} 

Example

curl -T "myapp.war" "http://manager:manager@localhost:8080/manager/text/deploy?path=/myapp&update=true" 

Security

Keep in mind the server must be able to accept your remote IP. This is a sample configuration:

<Context privileged="true" antiResourceLocking="false"          docBase="${catalina.home}/webapps/manager">   <Valve className="org.apache.catalina.valves.RemoteAddrValve"          allow="127\.0\.0\.1" /> </Context> 

This is an optional setting and isn't required but having Cross domain role and proper manager credentials is a must.

Tomcat 8 - the same rules apply as Tomcat 7. Same commands.

Here is a full documentation:

http://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html

like image 58
jeveloper Avatar answered Oct 05 '22 13:10

jeveloper


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" 

Example:

curl --upload-file target\debug.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 
like image 44
s3v1 Avatar answered Oct 05 '22 14:10

s3v1