๐Ÿš€ Day 8/30 โ€” Jenkins Setup & Freestyle Project | DevOps Interview Preparation

Welcome to Day 8 of the 30 Days of DevOps Interview Preparation Challenge!
Today, weโ€™ll cover Jenkins, one of the most widely used CI/CD automation tools, and learn how to set it up along with our first Freestyle Project.


๐Ÿ“– 1. Understanding Jenkins

Jenkins is an open-source automation server written in Java. It helps automate:

  • Building code

  • Running tests

  • Deploying applications
    โ€ฆ all in a continuous integration and continuous delivery (CI/CD) pipeline.

Key Features:

  • Plugin Ecosystem: 1,800+ plugins to integrate with SCMs, build tools, cloud platforms.

  • Cross-Platform: Runs on Windows, macOS, Linux.

  • Extensible: Supports both Freestyle jobs and scripted pipelines.

  • Integration: Works with GitHub, Bitbucket, GitLab, AWS, Docker, Kubernetes, etc.

Why Jenkins is Popular in DevOps:

  • Free & Open Source

  • Huge community support

  • Flexible for small teams & enterprises

  • Easy to install and configure


๐Ÿ— 2. Setting up Jenkins on AWS EC2

Weโ€™ll use Ubuntu 22.04 EC2 Instance for this setup.

Step 1 โ€” Launch an EC2 Instance

  1. Go to AWS Console โ†’ EC2 โ†’ Launch Instance.

  2. Select Ubuntu 22.04 LTS.

  3. Instance type: t2.small or higher.

  4. Configure security group:

    • Allow SSH (22) from your IP.

    • Allow HTTP (80) from Anywhere.

    • Allow Custom TCP 8080 from Anywhere.

  5. Launch the instance.


Step 2 โ€” Install Java

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

Step 3 โ€” Install Jenkins

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null

echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null

sudo apt update
sudo apt install -y jenkins

Step 4 โ€” Start & Enable Jenkins

sudo systemctl start jenkins
sudo systemctl enable jenkins

Step 5 โ€” Access Jenkins UI

  1. Open browser:
    http://<EC2-Public-IP>:8080

  2. Get admin password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  1. Paste it in the UI โ†’ Install Suggested Plugins.

  2. Create Admin User โ†’ Save.


๐Ÿ›  3. Creating Your First Freestyle Project

A Freestyle Project in Jenkins is a flexible, simple job configuration for building and deploying projects.

Steps:

  1. On Jenkins Dashboard โ†’ Click New Item.

  2. Enter a name โ†’ Select Freestyle project โ†’ OK.

  3. Source Code Management:

    • Select Git

    • Enter GitHub repo URL

    • Add credentials if private.

  4. Build Triggers:

    • Optionally enable Poll SCM or Build periodically.
  5. Build Steps:

    • Click Add build step โ†’ Select Execute shell.

    • Example:

        echo "Building project..."
        mvn package
      
  6. Save โ†’ Click Build Now.

  7. Check Console Output to see logs.


๐ŸŽฏ 4. Interview Preparation Guide

Common Jenkins Interview Questions:

Q1: What is Jenkins and why do we use it?
A: Jenkins is an open-source automation server that helps implement CI/CD by automating the build, test, and deployment processes. It increases software delivery speed, ensures consistency, and reduces human errors.


Q2: What is the difference between Freestyle and Pipeline jobs?
A:

  • Freestyle: GUI-based configuration, simpler, less scalable for complex workflows.

  • Pipeline: Code-as-configuration (Jenkinsfile), better for complex, multi-step, version-controlled pipelines.


Q3: How can you secure Jenkins?
A:

  • Enable authentication & authorization.

  • Use Role-Based Access Control (RBAC) plugins.

  • Secure Jenkins with HTTPS.

  • Restrict script execution.

  • Keep Jenkins and plugins updated.


Q4: How do you integrate GitHub with Jenkins?
A:

  • Install Git plugin.

  • Configure GitHub webhook to http://<jenkins-url>/github-webhook/.

  • Add repo URL in job SCM settings.


Q5: What are some useful plugins for Jenkins?
A:

  • Git plugin

  • Pipeline plugin

  • Email Extension

  • Blue Ocean UI

  • Docker plugin


๐Ÿ’ก Pro Tips for Real Projects

  • Use Pipeline jobs for scalability, Freestyle for quick tasks.

  • Keep Jenkins jobs & configs in source control.

  • Set up build notifications (Slack, Email).

  • Use agents for isolated builds to avoid conflicts.


๐Ÿ“Œ Conclusion:
Today, we learned how to set up Jenkins on AWS EC2, create our first Freestyle Project, and prepare for Jenkins-related interview questions. Tomorrow, weโ€™ll go deeper into Jenkins Pipeline Projects.


#30DaysOfDevOps #Day8 #Jenkins #AWS #DevOpsInterviewPrep #FreestyleProject #CICD #HashnodeBlog

0
Subscribe to my newsletter

Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tathagat Gaikwad
Tathagat Gaikwad