Simple CI/CD pipeline Integrating Jenkins with Maven and GitHub to Build a job on a Tomcat server.
date
Apr 26, 2024
slug
simple-ci-cd-devops-project
author
status
Public
tags
DevOps
Jenkins
Projects
Maven
Tomcat
Github
summary
A company would use a CI/CD pipeline integrated with Jenkins, Maven, GitHub, and Apache Tomcat to streamline and automate the software development and deployment processes.
type
Post
category
📢 DevOps Blogs
updatedAt
Apr 25, 2024 05:58 PM
Overview:
A company would use a CI/CD pipeline integrated with Jenkins, Maven, GitHub, and Apache Tomcat to streamline and automate the software development and deployment processes. Jenkins serves as the automation server, orchestrating the pipeline, while Maven manages project dependencies and builds. GitHub acts as a version control system, enabling collaboration, and Apache Tomcat facilitates the smooth deployment of applications, ensuring efficient and consistent delivery of software updates. This integrated toolchain enhances development speed, ensures code quality, and simplifies the continuous delivery of software applications.
Objectives:
- Setup Jenkins
- Setup & configure Maven and Git
- Setup Tomcat Server
- Integrating GitHub, Maven, Tomcat Server with Jenkins
- Create a CI and CD job
- Test the deployment
Prerequisite:
- AWS account(free-tier)
- Java-open-jdk11
- PowerShell
- GitHub account
♾️Step 1: Set up Jenkins
1. Install Jenkins on an Amazon Linux 2 AMI EC2 instance using the official guide.
sudo wget -O /etc/yum.repos.d/jenkins.repo \https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key sudo yum upgrade sudo yum install fontconfig java-17-openjdk sudo yum install jenkins
2. Name the EC2 instance, choose Amazon Linux 2 AMI, and configure security groups to expose port 8080.
3. Connect to the instance via SSH and install Jenkins using the Red Hat package.
4. Resolve Java compatibility by installing EPEL and Java 11.
sudo amazon-linux-extras install epel sudo amazon-linux-extras install java-openjdk11
5. Start Jenkins, obtain the public IPv4 address, and access Jenkins in the browser.
♾️Step 2: Open Jenkins, set up an admin account, and install plugins.
1. Unlock Jenkins using the initialAdminPassword.
2. Close plugin customization and start using Jenkins.
3. Create a Freestyle project named “HelloWorldJob” with a simple shell script.
4. Build the job and check console output for success.
🥇Congratulation you have successfully created your Jenkins server and executed your first job!!!
♾️Step 3: Install and configure Maven and Git
1. Install Git on the Jenkins machine using
yum install git
.2. Configure Git plugin in Jenkins.
🥈Congratulation you have successfully installed and configured Git on your Jenkins machine!!!
3. Install Maven on the Jenkins machine from a binary tar.gz file.
4. Configure Maven in Jenkins under the Tools tab.
♾️Step 4: Setup Tomcat Server
1. Download and install Apache Tomcat 10 on an EC2 server.
2. Configure security groups to allow traffic on port 8080.
3. Install Java on the server using amazon-linux-extras.
4. Install and configure Tomcat by downloading and extracting the files.
5. Start Tomcat and access it through the browser.
6. Edit context.xml files to allow external access to the Manager app.
7. Configure users and roles in tomcat-users.xml.
8. Restart Tomcat and log in to the Manager App.
♾️Step 5: Integrate GitHub, Maven, Tomcat Server with Jenkins
1. Download the Deploy to Containers plugin in Jenkins.
2. Configure global credentials for Tomcat server in Jenkins.
3. Create a new Jenkins job named “BuildAndDeployJob” as a Maven project.
4. Configure the job to connect to the GitHub repository.
5. Set build goals, options, and post-build actions to deploy artifacts to the Tomcat server.
6. Build the job and observe the process.
♾️Step 6: Test the Deployment
1. Clone the hello-world repo to a local machine.
2. Make modifications to the code and commit changes to trigger CI/CD jobs.
3. Verify successful deployment on the Tomcat server.
🥉Congratulation you have now installed Maven and built your very first project from GitHub on a Tomcat server using Jenkins as your CI/CD pipeline!!!
Conclusion!
By following these steps, you should have a robust CI/CD pipeline set up with GitHub, Jenkins, Maven, and Tomcat, facilitating efficient and automated application development and deployment. Hopefully this tutorial was fun and informative. Thank you for following along, happy coding!
Thank you for reading my blog …:)
© Copyrights: ProDevOpsGuy
Support 🫶
- Help spread the word about ProDevOpsGuy by sharing it on social media and recommending it to your friends. 🗣️
- You can also sponsor 🏅 on GitHub Sponsors // 🎗️ Support Our Work 🎗️
Thank you for reading this long article.
Feedback on typos and content is always welcome.
#DevOps#Github#Jenkins#Maven#Projects#Tomcat