Integrating Jenkins and Apache Tomcat for Continuous Deployment

posted by jfullam on March 20, 2012 04:32 PM

Working software is the primary measure of progress for software development teams. This is one of the principles of the Agile Manifesto and has led agile software teams to focus on implementing the most important features of a system early and efficiently. These teams usually provide frequent deployments of the software in order to receive feature validation from the business and to show project progress. The benefits are quick and frequent feedback for the developers and congruous applications for the business.

The practice of automated continuous deployment ensures that the latest checked in code is deployed, running, and accessible to various roles within an organization. Project managers can have a place to check on project progress, testers have a view into the latest builds, developers can see the their modules working with the modules from other team members, and stakeholders can see how their requirements have been translated into working software. Tomcat and tc server easily integrate with continuous integration servers to allow agile teams to realize continuous deployment while utilizing a lean application server (another practice of agile teams). You can start practicing continuous deployment very quickly using Tomcat or tc server, Jenkins, and your source control system of choice.

Configuring Jenkins to Build Your Project

Jenkins is a popular continuous integration server that is easy to install and configure. Installation is a simple as deploying the downloaded war file to your Tomcat webapps directory. The Jenkins interface is the accessed through a web browser. Assuming you have a JDK installed and you have a build tool already in place (ANT, Maven, etc), you can automate the building of your project in a few simple steps.

You will need to install a plugin to access your source control system. In my case, I used the GIT Plugin . You will also need a plugin that allows the interaction with Tomcat or tc Server from the command line. I use the Post Build Task plugin to allow me to execute a shell task after my build tasks have completed. Installing plugins is accomplished by accessing the “Manage Jenkins” page and choosing the “Manage Plugins” link. The plugins mentioned can be selected and installed from the list of available plugins.

Once Jenkins is installed and you have the necessary plugins enabled, you can create a new job and configure it to monitor your source control system. The first step is to point to your project in source control.

The next step is to configure when Jenkins should build your project. This is accomplished by using a cron expression to specify the frequency of a build or how often to poll for changes in your source control system before building.

In this case Jenkins will poll for changes in source control every 5 minutes. The frequency for building and deploying your application depends on who will be looking at the application. It could be sufficient to build the latest source every night, ensuring interested parties will have a fresh deployment to evaluate on a daily basis.

Deployment with Apache Tomcat

The Tomcat manager application allows remote deployment to an instance of Tomcat. In this case, you need to configure Tomcat to allow access to the manager application through the plain text interface. This is accomplished by assigning the manager-script role to the credentials that will be performing deployments. This configuration depends on which Realm implementation you are using. The following example is utilizing the default MemoryRealm which reads an XML formatted file stored at $CATALINA_BASE/conf/tomcat-users.xml.

	<user password="tomcat" roles=" manager-script" username="tomcat">

Next, you need to configure your job in Jenkins to utilize the manager interface in order to deploy your recently built application. This is configured using the Post Build task plugin.

You can use wget, curl, or a similar tool to call the manager HTTP interface. It is necessary to first undeploy the application before deploying the new build. This avoids issues with deploying to an existing context path. The location of the newly built application war file can be determined by examining the output from a previous Jenkins job execution for that job.

wget "http://tomcat:password@localhost:8080/manager/text/undeploy?path=/spring-travel" -O - -q
wget "http://tomcat:password@localhost:8080/manager/text/deploy?path=/spring-
   travel&war=file:<path to="" war="">" -O - -q

Deployment to tc Server

Often times, an application needs to be deployed across several different environments. This could be because the application is clustered, there are dedicated instances for dedicated teams, or there is a need to test the application on different platforms. VMware vFabric tc Server provides centralized management and monitoring of server instances and groups of instances through its built in integration with vFabric Hyperic. The following steps assume you’ve installed the Hyperic server and a Hyperic agent is installed on the machines containing tc Server.

To group instances of tc server together, click the Resources > Browse link located at the top of the Hyperic web interface. You then select the tc server resources you’d like to group and click on the group button.

Once you have a group defined, you can let Hyperic manage the deployment of your application to a single or group of tc Server instances.

To access the tc Server management capabilities from Jenkins (and the command line), you need to download and configure the tcsadmin interface from Hyperic. This is available for download from your Hyperic server under the Administration tab. You will need to download and unzip this file on the same server that is running your Jenkins CI server. You can optionally add the or tcsadmin.bat script to your system PATH.

In order for tcsadmin to communicate with the Hyperic server, you need to provide the commands with server location and credentials. To avoid including the credentials in the Jenkins job configuration, specify connections parameters in a file called in a .hq sub-directory of the home directory of the user running Jenkins.


Replace the Tomcat manager calls in the Jenkins job configuration with calls to undeploy-application --groupname=spring-travel-group --application=spring-travel deploy-application --groupname=spring-travel-group --localpath=<path to="" war=""> 

Using the tcsadmin interface allows you to configure a job in Jenkins once without the need to make modifications when changing or adding servers to the group targeted for continuous deployment.


It is important to note that there are other ways to accomplish continuous deployment using these technologies. For example, you could have the deployment triggered from your ANT or Maven based build tools and use Jenkins purely for triggering the build. The important point is that agile teams typically gravitate towards lean runtimes such as Tomcat and tc Server for their java applications and the benefits of continuous deployment can be easily integrated into these lean runtimes utilizing popular tools for building software, continuous integration, and source control.

Jonathan Fullam has over 12 years of experience with software development with a heavy focus on enterprise Java based applications and open source frameworks. Currently employed by SpringSource, a division of VMware, Jonathan advises enterprises on building scalable architectures using modern technologies and tools.  With a passion for public speaking, he most recently presented Test Driven Developement at the 2011 Java Server Side Symposium.  Jonathan received his education from The College of New Jersey where he obtained a B.S. in computer science.


Using maven

you could also use cargo:deploy. My jenkins build is configured with
maven clean install cargo:deploy

This will build and install the war and then deploy it to a defined server in the pom.xml. You can even add a ping tag to see if the application can startup successfully. If this fails the build will fail and you will receive an email (if thus configured)


jenkins can deploy directly to tc-server

I'm running an app on a development system running VMware vFabric tc Runtime 2.7.1.RELEASE/6.0.35.B.RELEASE, and am able to deploy to the embedded tomcat 6.0 instance using the Jenkins Deploy directly to Container plugin It seems to work exactly like any other Tomcat 6.0 instance in this respect. That is, there was no need to employ Hyperic to manage the deployment.


Deploying to Hyperic

I am trying to setup automated builds that deploy to a group in Hyperic from Jenkins.Your article does a nice job walking through the setup, but seems to leave off near the end. What exactly do I need to do in Jenkins to get it to deploy my war to the Hyperic group at the end of the build? Do you setup a script in "Post Build Tasks"? What is the syntax of the commands to undeploy the war (if it's already deployed on the group in Hyperic), then deploy the newly built war from Jenkins using the user name and password saved in the .hq directory in the Jenkins home directory? Ideally I would like to not have the admin Hyperic user ID and password visible in the build configs.


Thanks for your comment.

Thanks for your comment. This is now fixed.


Thanks for showing this awesome post APP download and click and click and click and click and click

Your publish had provided me

Your publish had provided me with another point of view on this topic. I had no strategy that things can possibly work on this way as well. Thank you for sharing your opinion. Obat Kista.
obat gagal ginjal.


Actually Apache Tomcat is not that difficult to use. Yes as a beginner, I also found it a bit difficult to install and use, but then with the updates for the Apache server, it became an easy job to use the server. Network Security


hack real racing 3 android For this web site, you will see our account, remember to go through this info. gems gratuit clash of clans


Our watch of your respective websites usually speak out loud using countless of your respective audience We are truly satisfied. I have discovered me wanting on this occasion. I'd personally commonly make this happen me though the get can be very enormous along with our freelance writers are generally out of stock currently. Just about any tips? instagram for pc

Oh my goodness! Amazing

Oh my goodness! Amazing article dude! Thank you so much, However I am experiencing troubles with your RSS. I don’t know the reason why I am unable to join it. Is there anybody having identical RSS issues? Anyone who knows the answer will you kindly respond? Thanx!!
Mortgage Broker Calgary

Saying bender gucci bags, I

Saying bender gucci bags, I admission Hermes Replica bags to acceptance Gucci 85 ceremony bound copy handbags. It is so fantastic. In adjustment to bless the 85th ceremony of enactment of the brand. Gucci's helmsman Frida Giannini launched a alternation of bound copy handbags. There are abounding colors, patterns and abstracts in this Hermes Replica Handbags alternation distinctively designing for this 85th anniversary. From the architectonics to style, they all abstruse from the archetypal brand. The architectonics afflatus of two Bridle and Tartan Web are all from the history of Gucci authoritative the horsemanship products. Bridle architectonics is from the archetypal arrangement of Horsebit and horse reins composition. The Tartan Web is printed with acclaimed Louis Vuitton Replica Handbags red and blooming band arrangement Fiber of the brand, which is colorful. In addition, some accoutrements are bogus from the acclaimed and adored covering like crocodile skin, snake ski. Able handwork.

You ought to be a part of a

You ought to be a part of a contest for one of the highest quality websites online. I most certainly will recommend this blog!
Edmonton Mortgage Broker
Life Insurance Vancouver
Life Insurance Calgary


Check out free demo of all certifications Exam.  Save your time and get on time success in Cisco certification 300-209 Practice Tests

In ruler areas the education

In ruler areas the education is not deliver to the womans, they thought womans don’t need education. In such area the best dissertation writing services social workers doing the great work and they illustrate peoples about the importance of woman education.

Hi jfullam, We are using

Hi jfullam,
We are using Apache Tomcat and most frequently replace the modified jsp, class and html files in the context manually to update the pages.
Can we take the help of Jenkins to make it automate?

In making that supposition,

In making that supposition, individuals ignore the significant difficulties that come up in aesthetic oral promotion dental website marketing.

Today, once you point out

Today, once you point out beneficial, that appears like any supporting palm definitely not living conserving.nonetheless, will be strictly lifesaving! They will compose the most effective dissertations inside the quickest moment achievable use this link.

This post is very useful to

This post is very useful to know the performance tuning of Apache Tomcat for production. I think this is an important topic that we must know about Apache Tomcat. I hope most of the readers will enjoy this opportunity. SEO Freelancer Mumbai

It makes no difference at

It makes no difference at this level if you can' think of anything to obtain in conditions of material, but having a plan is important. If you don't have an itemized down routine of when you will produce your web page, you will be unlikely to do it good.

I also benefit from learning

I also benefit from learning the assessments, but learn that alot of people ought to stay on essay to przepis-na-sos-pieczarkowy try and add worth in the direction of the authentic weblog release.

Great Guide!

Hey thanks for the tutorial it helped a lot!

One question. I managed to do everything up to the "Deploy to tomcat" part. I now have my folder structure (structured like in eclipse) in my jenkins/workspace folder. Following the steps mentioned in the deploying part does not work for me.
Do i have to push a .war file, or is the war built by jenkins?

Daftar Harga Atap Spandek Sni Dari Supplier Pabrik Daftar Harga Plat Bordes Kembang Dari Distributor Pabrik

konstruksi baja pada jembatan konstruksi baja hanggar
proses pendahuluan sebelum diolah dalam dapur pengolahan logam dengan cara dipecah sebesar kepalan tangan, dipilih yang mengandung unsur logam, dicuci dengan air proses pendahuluan sebelum diolah dalam dapur pengolahan logam dengan cara dipecah sebesar kepalan tangan, dipilih yang mengandung unsur logam, dicuci dengan air proses pendahuluan sebelum diolah dalam dapur pengolahan logam dengan cara dipecah sebesar kepalan tangan, dipilih yang mengandung unsur logam, dicuci dengan air

cool post

cool post
لعبة المزرعة السعيدة


navratri wishes

navratri images

dandiya songs

Thesis Writing Service

Tremendous post as always!
Thesis maker service is here for students.

Thesis maker

I just found this blog and

I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.