Pages

Sunday, September 23, 2018

Jenkins - Integrating with Tomcat

As a part of CI/CD , Some time Jenkins will be doing the part of the Deployment tool. Jenkins multiple plunges to deploy packages to different types of end points. One of the normal use case is to deploy your java war package to a web server like tomcat. In this article we will see how one can deploy a java war file to a tomcat server. For the demo purpose we will be using the “Deploy to a container” plugin.

1.Install the Plugin from the Manage Jenkins -> Package Manager 
2. We don’t need to configure any thing for this plugin. 
3. This plugin supports deployment to multiple containers like jboss, tomcat etc 
4. Go to your maven job , and Select “Deploy ear/war to a Container” and we will see seeing a window like below attached, 
We need to fill some of the fields in the window as, 
War/Ear file location 
Context path to deploy to container 
Now choose the container ( tomcat 7.x here ) and fill the details of the url where that server can be accessed and also credentials to login to the machine. Once done , run the job and we can see that the war file is deployed to the tomcat and can be see with the same context that we have given. 

Note - There are few issues with the tomcat roles while configuring this plugin. The role and user in tomcat should be configured correctly to enable the communication between Jenkins and Tomcat. 

Below is the my configuration in the tomcat-user.xml file for more details. Iam using the “system/system” credentials configured in Jenkins for accessing the server. 
 <role rolename="manager-gui"/> 
<role rolename="manager-script"/> 
<user username="tomcat" password="tomcat" roles="manager-script,manager-gui,admin-gui"/> 
<user username="system" password="system" roles=“manager-script,admin-script,manager-gui"/> 

More to Come ,Happy learning :-) 

No comments :

Post a Comment