Tomcat manager remote deploy script

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

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

Tags:

Curl

Tomcat