Jenkins Tomcat Deployment
Jenkins Tomcat Deployment
Jenkins Tomcat Deployment
Step-1: Launch Two Instances: Initialize two separate servers — one dedicated to
Jenkins and the other for Tomcat.
Server Configuration:
Jenkins Server Setup: Install and configure Jenkins on the first server.
Tomcat Server Setup: Install and configure Tomcat on the second server.
Note: Ensure that the Tomcat server has similar configurations to the Jenkins
server to maintain consistency in performance and security settings.
At the "Branches to build" option, the default branch name is set to "master."
Make sure to modify it to the correct branch name accordingly.
Note: I have the Netflix-Signup repository in my GitHub. You can fork it to your
own GitHub.
https://github.com/charan-kilana/Netflix-SignUp-Page.git
Step-4: Installing Java 1.8 (OpenJDK) and Maven on the Jenkins Server.
Step-5: Under Build Steps, configure the build process to compile your project,
ensuring it generates the desired WAR, JAR, or EAR file upon completion.
Step-6: Build the job.
After building the code with "Invoke top-level Maven targets," you will get a
packaged WAR file in the target folder. You should now deploy this WAR/JAR/EAR
file in Tomcat.
Step-7: Setting Up Tomcat
Download java of any version
Go to the folder apache-tomcat-9.0.93 >> bin, and in the bin folder, you will find
the startup.sh script to start Tomcat.
Access the public_Ip_addresss along with port number (8080).
To deploy the application, you must first log in. If you navigate to the manager,
you'll receive an "Access Denied" message.
By default, the Manager is only accessible from a browser running on the same
machine as Tomcat. If you wish to modify this restriction, you'll need to edit the
Manager's context.xml file.
Before using the locate command to find the context.xml file, ensure the database
is updated with the command: sudo updatedb. This will ensure all files, including
context.xml, are indexed and searchable.
Open the context.xml file in the Vim editor and delete lines 21 and 22:
Open the File:
Launch the Vim editor with the command: vim context.xml
Navigate to the Lines:
Go to line 21 by typing: 21G in command mode.
Delete the Lines:
Delete line 21 by typing dd. This command deletes the current line.
Delete the next line (previously line 22) by typing dd again.
Save and Exit:
Save the changes by typing :wq and pressing Enter. This command writes
the changes to the file and exits the editor.
Go to line 50, copy the next three lines, paste them into the tomcat-users.xml
file, and modify the credentials as necessary.
Add the role names manager-gui and manager-script, set the username as tomcat,
and add a password. Assign the roles manager-gui and manager-script under the
roles section.
Note: Whenever you change the configuration, you should restart the server.
Since you've modified the configuration, go to the bin directory and restart the
server.
Now, when you log in to the Tomcat dashboard, you should enter the credentials
you configured.
Below is Tomcat dashboard.
Step-8: Deploy the WAR/EAR/JAR File in Tomcat
Install the "Deploy to Container" Plugin:
Go to the Jenkins dashboard.
Navigate to Manage Jenkins > Manage Plugins > Available.
Search for the "Deploy to Container" plugin and install it.
Configure the Job:
After installing the plugin, return to your job on the Jenkins dashboard to
configure the deployment settings.
Step-9:
Here's a refined version of your instructions for configuring Jenkins to deploy
using the "Deploy to Container" plugin:
1. Navigate to Job Configuration:
o Go to your job in Jenkins and click on Configure.
2. Set Up Build Steps:
o Scroll to Build Steps and proceed to Post-build Actions.
3. Configure Deployment:
o Select Deploy war/ear to container from the dropdown menu. This
option is available only if you have previously installed the "Deploy to
Container" plugin.
To configure the deployment of your packaged WAR/EAR file in Jenkins and
specify the display name or application name in Tomcat.