I decided to provide automatic deployment of war packaged application using Jenkins and Deployment plugin. The target platform is Amazon with Tomcat 7, see nice set of articles to find out how to setup such environment for free.
Well, there is couple of tutorials but they missing some points so it pushed me to lost one hour of my work.
What I got
- Fresh installation of Tomcat 7 on remote machine with opened 8080 port on firewall
- Personal war file supposed to be deployed
How to push it to tomcat?
1. First of all, there is simple configuration of tomcat users in file tomcat-users.xml – it was my pain in the ass 🙂 As original comprehensive documentation says, it’s necessary to define user, but which one(s)?
Here is working example of tomcat-users.xml:
The important part is manager-script, contrary to Tomcat 6 where it had not exist yet. This user allows access to /text sub-namespace in management uri. The first user called manager-gui is the one which you use in GUI console, e.g. http://localhost:8085/manager/html
Once you run tomcat using bin’s bat file, you can move to second bullet.
2. Now, it’s possible to use remote deployment using curl command, e.g. in my use-case:
curl –upload-file my.war “http://manager-script:changeit@localhost:8080/manager/text/deploy?path=/myPath&update=true”
The command is working using manager-script user contrary to my original manager-gui. Another interesting part is path=/myPath. This attribute say which URL sub-namespace is to be used.
Even if you deploy my.war and common Tomcat’s approach is to deploy application in /my subname, the application is to be exposed on /myPath.