The latest version of the Jenkins can be downloaded from the below.
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.
Since we want to deploy Jenkins in Tomcat., download the Generic Java package (.war).
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.
The Jenkins can be hot deployed into Tomcat using the Tomcat manager page. Access the tomcat manager page through the below url.
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.
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.
In ‘Deploy’ section, click on Browse and select the jenkins.war file which we downloaded at the beginning and click on Deploy.
The Jenkins application is deployed and you can now see it in the list of Applications.
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.
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.
The Jenkins war will be extracted in the webapps folder and it should look similar to the below.
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.
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.
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’.
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.
Some of commonly used plugins are downloaded and configured.
The initial Admin password provided earlier is valid only for once, so we need to create an Admin User Account.
Provide the username, password, confirm password, full name and email address and click on ‘Save and Continue’.
We can configure the url we want to use to access Jenkins. Let us leave the default and continue.
The Jenkins set up is completed and ready to use.
The Jenkins logs into the app with the admin user account you created earlier and below is the Jenkins default home view.
Navigate to Tomcat manager page by appending /manager/html to your tomcat url.
Replace localhost with your dns if you are working remotely.
Enter the manager user name and password.
In Applications list, click on ‘Undeploy’ button against the Jenkins application.
The result of the undeploy is displayed in the Message area below the Tomcat Web Application Manager title.
Some times, the undeploy may not be successful, so you need to navigate to the webapps folder and delete the application folder.
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.
In this blog, we have deployed Jenkins in Tomcat, did the initial configurations and the Jenkins installation is ready for use.