Jenkins CI/CD Pipeline to Deploy Java Application on Tomcat Server

Sudheer
4 min readOct 6, 2023

--

Use Jenkins to set up a CI/CD pipeline that will compile and test a Maven project and deploy it to a Tomcat Server.

Project description:

  1. The project aims to automate the building, testing and deployment process of web application using Jenkins, GitHub and Tomcat server.
  2. The pipeline will include stages such as check out code from GitHub, building, archive artifact, deployment on tomcat server and send notification.

Use the following:

  1. Java: To create the website.
  2. Git: As a version control system for the program.
  3. Jenkins: To create the build pipeline.
  4. Maven: To compile the program.
  5. Tomcat: To host the website.
  6. AWS EC2: To run Tomcat.

Create AWS EC2 Instance.

Create Key-Pair

EC2 Instance is launched successfully.

Connect to EC2 Instance

Connected to EC2 Instance

Update the Instance.

$ apt update

Install Java JDK

Install Tomcat9 Server on EC2 instance.

Open tomcat user to add the users.

$ vi tomcat-users.xml

Add username, password and roles for the user under <tomcat-user>.

Restart the service.

$ service tomcat9 restart

To add port 8080 for an instance, you need to allow traffic on port 8080 in instance security group and configure the instance firewall to allow traffic on port 8080.

Now, Access the tomcat server with Public IP and Port 8080

Provide Username and password that we configured in tomcat-user.xml under <tomcat-user> tag.

Successfully accessed Apache Tomcat server UI.

Create CI/CD pipeline to build and deploy the application on Tomcat server.

Create Pipeline project and give the name.

Provide Git URL for the project and Select tomcat credentials to deploy the application.

To add tomcat credentials, Click AddàProvide tomcat server credentials (Username and Password).

Pipeline code to build and deploy the application on tomcat server.

CI/CD Pipeline job successfully built and deployed the application on the server.

Java Application deployed on the server. Open the application.

Java Application accessed using Public IP, Port Number: 8080 and Application URL.

Thank you for reading.

Sudheer Baraker.

--

--