Deploying Jenkins in Tomcat

 

Download

The latest version of the Jenkins can be downloaded from the below.

https://jenkins.io/download/

The LTS version receives updates every 12 weeks while the Weekly version receives an update every week, which might be an overkill to maintain. So download the Long Term Support (LTS) version.

Select the download for the environment you are going to install Jenkins on.

 

 

a0

Since we want to deploy Jenkins in Tomcat., download the Generic Java package (.war).

 

Installation

 

Since you are planning to deploy Jenkins in Tomcat, the Java and Tomcat must already be installed on your machine. Download the war file from the Jenkins download link.

 

a1

 

The Jenkins can be hot deployed into Tomcat using the Tomcat manager page.  Access the tomcat manager page through the below url.

http://localhost:8080/manager/html

If you are accessing the tomcat remotely replace localhost with the server dns.

Provide the manager user name and password to access the manager page.

image

 

The Tomcat manager page is displayed. Below ‘Applications’ section, there is a ‘Deploy’ section which provides options to do hot deployments of the web applications.

 

image

 

In ‘Deploy’ section, click on Browse and select the jenkins.war file which we downloaded at the beginning and click on Deploy.

 

image

 

image

 

The Jenkins application is deployed and you can now see it in the list of Applications.

image

 

Some times the deployment fails and the Tomcat doesn’t give much information in the web view and displays the browsers default connect reset page similar to below. This page may wary based on the browser you are using.

 

image

 

If you look up the Tomcat logs for the cause of the failure, you may find some thing similar to below.

FAIL – Deploy Upload Failed, Exception: [org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (75715094) exceeds the configured maximum (52428800)]

If this is the case, follow these steps and then redeploy the jenkins web application again.

 

If you don’t want to do hot deployment, then copy the downloaded jenkins.war file into Tomcat webapps folder and restart the Tomcat service.

 

a01

 

The Jenkins war will be extracted in the webapps folder and it should look similar to the below.

 

 

a02

 

And open the browser and type http://localhost:8080/jenkins to configuring the Jenkins. The Tomcat normally runs on 8080, but if you have configured the Tomcat to use another port, use that port to access the Jenkins app instead of the default 8080 port.

 

a2

 

If the Jenkins is installed as a service, then all the Jenkins workspace is within the Jenkins folder. But in this case, it is a deployed as webapp in Tomcat server, so the workspace is created at a different location. The Jenkins workspace will be created at C:\Users\<User Account>\.jenkins, Where <User Account> the username of the windows account with which the Tomcat is running.

 

a4

Once the Jenkins completes configuring the backend, it asks for the temporary administrator password in the Unlock Jenkins Password page. The location of the temporary password is also indicated in the same page. Enter the password from the ‘initialAdminPassword’ file and click on ‘Continue’.

a3

 

Once the initial Admin password is entered, Jenkins starts doing the configurations.

 

In Getting started page, you can select either to Install suggested Plugins, which installs some commonly used plugins or Select plugins to install, where we need to select the plugins we need. To keep it simple, we will select the Install suggested plugins. We can modify the plugins later if we need to.

 

 

15

Some of commonly used plugins are downloaded and configured.

 

a5

 

The initial Admin password provided earlier is valid only for once, so we need to create an Admin User Account.

 

a6

 

Provide the username, password, confirm password, full name and email address and click on ‘Save and Continue’.

 

a7

 

We can configure the url we want to use to access Jenkins. Let us leave the default and continue.

 

a8

 

The Jenkins set up is completed and ready to use.

 

a9

 

The Jenkins logs into the app with the admin user account you created earlier and below is the Jenkins default home view.

 

a10

 

Un-Deploying Jenkins

 

Navigate to Tomcat manager page by appending /manager/html to your tomcat url.

http://localhost:8080/manager/html.

Replace localhost with your dns if you are working remotely.

Enter the manager user name and password.

image

 

In Applications list, click on ‘Undeploy’ button against the Jenkins application.

image

 

The result of the undeploy is displayed in the Message area below the Tomcat Web Application Manager title.

 

image

 

Some times, the undeploy may not be successful, so you need to navigate to the webapps folder and delete the application folder.

image

 

If you see message like this indicating a failure with undeploying jenkins, navigate to the Tomcat webapps folder and delete the jenkins folder and then restart Tomcat.

 

Or you can try restarting Tomcat and then clicking on ‘Undeploy’ against Jenkins application in the same process again.

 

Conclusion

In this blog, we have deployed Jenkins in Tomcat, did the initial configurations and the Jenkins installation is ready for use.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s