← Back to DevOps
© 2025 sampathirao yoganandh
Week 3 & 4 · CO-2

Jenkins & CI/CD

Freestyle Jobs, Pipeline Jobs, CI/CD Pipeline with Maven & Tomcat on AWS  CO-2

Introduction to Jenkins

Jenkins is an open-source automation server used to implement Continuous Integration (CI) and Continuous Deployment (CD). It allows users to create different types of jobs to automate tasks like building, testing, and deploying applications.

Key Point Jenkins is the most widely used CI/CD tool in DevOps. It connects your code repository (GitHub) with your build tools (Maven) and deployment targets (Tomcat, Docker).

Freestyle Job

A Freestyle job is the simplest Jenkins job type. It allows you to configure build steps through the Jenkins UI without writing code. It is mainly used for basic automation tasks.

Steps to Create a Freestyle Job

  1. Open Jenkins dashboard in browser — http://<server-ip>:8080
  2. Click New Item
  3. Enter a job name
  4. Select Freestyle project → Click OK
  5. In Source Code Management, select Git and provide repository URL
  6. In Build Steps, click Add build step → Execute shell
  7. Enter build commands like mvn clean install
  8. Click Save → Build Now to run the job

Pipeline Job

A Pipeline job defines the entire build and deployment process as code using a Jenkinsfile. It provides better automation, version control, and complex workflow management.

Steps to Create a Pipeline Job

  1. Open Jenkins dashboard → New Item
  2. Enter a job name → Select Pipeline → Click OK
  3. Scroll to Pipeline section → Choose Pipeline script from SCM
  4. Select SCM as Git → Enter the GitHub repository URL
  5. Specify the branch (e.g., main or master)
  6. Set Script Path as Jenkinsfile
  7. Click Save → Build Now
Jenkinsfile Location The Jenkinsfile must be committed in the root of your GitHub repository. Jenkins pulls it automatically when the pipeline runs.

Freestyle vs Pipeline Jobs

FeatureFreestyle JobPipeline Job
ConfigurationVia Jenkins UIDefined as code in Jenkinsfile
Use caseSimple buildsComplex CI/CD workflows
Version controlHard to version controlEasily version controlled with Git
FlexibilityLimitedHighly flexible and scalable
Recommended forBeginners / learningProduction CI/CD pipelines

CI/CD Pipeline for Java Web Application

Aim: Automate the build and deployment of a Java Maven web application using Jenkins and deploy it to Apache Tomcat on AWS Ubuntu.

Tools & Architecture

ToolRole
Java 17Programming language runtime
Apache MavenBuild and dependency management
JenkinsCI/CD automation server
Apache TomcatWeb server to run WAR file
GitHubSource code repository
AWS EC2 UbuntuCloud server environment
Architecture Flow Developer → GitHub → Jenkins → Maven Build → WAR file → Tomcat → Browser

Step-by-Step Procedure

Step 1: Install Java 17

sudo apt update
sudo apt install openjdk-17-jdk -y
java -version

Step 2: Install Maven

sudo apt install maven -y
mvn -v

Step 3: Install Jenkins

sudo apt update
sudo apt install jenkins -y
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
# Access Jenkins at http://<EC2-IP>:8080

Step 4: Install and Configure Tomcat

sudo apt install tomcat10 tomcat10-admin -y
Port Conflict Jenkins and Tomcat both default to port 8080. Change Tomcat's port to 8090 to avoid conflict.
# Edit Tomcat server config
sudo nano /etc/tomcat10/server.xml
# Find: <Connector port="8080" protocol="HTTP/1.1"
# Change to: <Connector port="8090" protocol="HTTP/1.1"
Reference Repository Fork this repo for a working Jenkinsfile and Dockerfile:
https://github.com/syoganandh/spring-boot-maven-example-helloworld.git
📄

Jenkins & CI/CD — Notes PDF

Week 3 & 4 · Freestyle Jobs, Pipeline Jobs, Maven & Tomcat

⬇ Download PDF