Skip to main content

Command Palette

Search for a command to run...

Day 23 - Jenkins Freestyle Project

Published
โ€ข5 min read
Day 23 - Jenkins Freestyle Project
A

๐Ÿš€ Welcome to the world of DevOps with Aakash! ๐ŸŒ

Hey tech enthusiasts! ๐Ÿ‘‹ I'm Aakash, a dedicated freelance Linux System Admin @xFusionCorp, and I'm on a mission to conquer the world of DevOps. Currently, I'm immersed in building exciting projects and sharing my learning experiences with you all.

๐Ÿ› ๏ธ My Tech Arsenal:

  • Docker
  • Linux
  • Kubernetes
  • Jenkins
  • AWS
  • Python
  • Java
  • Prometheus
  • Grafana
  • Ansible
  • Terraform

Join me in navigating the intricate realms of AWS DevOps technology. Let's embrace learning with gratitude and thrive in this ever-evolving landscape!

๐Ÿค Connect with me for:

  • Friendly chats
  • Shared experiences
  • Learning moments

Follow my journey on Twitter and Linkedin for daily insights and tech goodness. Let's build, automate, and innovate our way through the exciting world of DevOps! ๐Ÿš€ #DevOps #AWS #TechEnthusiast #InnovationJourney #90DaysOfDevOps

Introduction

Greetings, DevOps enthusiasts! ๐Ÿš€ Today marks another thrilling milestone in our #90daysofdevops journey as we delve into the realm of Jenkins Freestyle Projects. So, buckle up and prepare to elevate your abilities to new heights!

Summarizing CI/CD:

Before we dive into the nitty-gritty of Jenkins Freestyle Projects, let's take a moment to refresh our knowledge of CI/CD concepts.

Continuous Integration (CI) automates the integration of code modifications from multiple builders into a single codebase, facilitating faster bug detection, improving software quality, and streamlining the integration process.

Continuous Delivery (CD) ensures error-free releases by automating the deployment process, making it seamless and efficient.

Exploring Build Jobs:

In Jenkins, build jobs are the backbone of automation. These jobs include the configuration for automating specific tasks in the software building process, ranging from compiling code to running tests and deploying applications.

Jenkins offers various types of build jobs, including freestyle projects, pipelines, multi-configuration projects, and more, to cater to diverse requirements.

The key points about build jobs in Jenkins:

  1. Purpose: Automate tasks in the software development lifecycle.

  2. Configuration: Defined using Jenkins web interface or Jenkinsfile.

  3. Build Steps: Individual tasks within a build job (e.g., compiling code, running tests).

  4. Post-Build Actions: Actions executed after build steps (e.g., archiving artifacts, sending notifications).

  5. Build History and Logs: Records build executions and provides detailed logs.

  6. Build Triggers: Events or conditions that initiate build executions (e.g., code commits, time schedules).

  7. Plugins and Integrations: Extends functionality and integrates with external tools and services.

Unveiling Freestyle Projects:

Now, let's unravel the concept of Jenkins Freestyle Projectsโ€”a versatile tool that empowers DevOps engineers to build, test, and deploy software with ease. Imagine you're working on an application deployed via Docker. Here's where Jenkins Freestyle Projects shine:

Hands-On Practice

Task-01

  • create a agent for your app. ( which you deployed from docker in earlier task)

  • Create a new Jenkins freestyle project for your app.

  • In the "Build" section of the project, add a build step to run the "docker build" command to build the image for the container.

  • Add a second step to run the "docker run" command to start a container using the image created in step 3.

Task-02

  • Create Jenkins project to run "docker-compose up -d" command to start the multiple containers defined in the compose file (Hint- use day-19 Application & Database docker-compose file)

  • Set up a cleanup step in the Jenkins project to run "docker-compose down" command to stop and remove the containers defined in the compose file.

Scenario-Based Tasks:

Task-01: Building and Deploying Docker Containers

Imagine you have developed an application deployed via Docker, and your mission is to create a Jenkins Freestyle Project to automate the build and deployment process. Let's break it down:

Solution:

  1. Set up an agent for your app:

    Begin by configuring an agent to handle the build and deployment tasks for your Dockerized application. You can specify this directly in your Jenkinsfile or in the Jenkins interface.

     agent any // Or specify a label for a specific agent
    
  2. Create a new Jenkins freestyle project:

    Within Jenkins, navigate to the dashboard and create a new freestyle project tailored to your application's needs.

  3. Configure the "Build" phase:

    In the project configuration, navigate to the "Build" section and add a build step to execute the "docker build" command. This step will build the image for your container.

     docker build -t your_image_name .
    
  4. Add a deployment step:

    Next, include a step to run the "docker run" command, launching a container using the image created in the previous step.

     docker run -d -p 8080:8080 your_image_name
    

Task-02: Managing Docker Compose

Now, let's raise the bar by orchestrating multiple containers defined in a Docker Compose file using Jenkins Freestyle Projects.

Solution:

  1. Create a Jenkins project:

    Start by creating a new Jenkins project dedicated to managing your Docker Compose setup.

  2. Configure the project:

    Within the project configuration, specify the necessary parameters to execute the Docker Compose commands.

     pipeline {
         agent any
         stages {
             stage('Deploy') {
                 steps {
                     sh 'docker-compose up -d'
                 }
             }
             stage('Cleanup') {
                 steps {
                     sh 'docker-compose down'
                 }
             }
         }
     }
    
  3. Start containers:

    Add a build step to run "docker-compose up -d," starting the containers defined in your Docker Compose file.

     docker-compose up -d
    
  4. Implement cleanup:

    To ensure proper resource management, set up a cleanup step to execute "docker-compose down," halting and removing the containers defined in the Compose file.

     docker-compose down
    

Conclusion:

In today's #90DaysOfDevOps challenge, we've embarked on a journey to master Jenkins Freestyle Projectsโ€”an integral tool for DevOps practitioners. From automating Docker container builds to orchestrating complex deployments with Docker Compose, we've covered significant ground.

Remember, continuous learning and hands-on practice are the keys to unlocking your full potential as a DevOps engineer. Keep exploring, keep innovating, and most importantly, keep pushing your limits.

Feel free to share your insights and experiences on LinkedIn using the #90DaysOfDevOps Challenge. Let's inspire and empower each other on this remarkable journey!

Stay tuned for more exciting challenges ahead. Until next time, keep thriving in the world of DevOps! Ending this with a quote

Build jobs in Jenkins are the heartbeat of automation, pulsing life into the software development process with each executed task.

Happy Learning.

90DaysOfDevOps

Part 18 of 39

In this series I will be positing my learnings of DevOps for 90 days continuously. We will be starting from the basics covering linux and will go upto covering the advanced concepts of DevSecOps.

Up next

Day 22 - Getting Started with Jenkins

Introduction Hey there, fellow DevOps enthusiasts and eager learners! Today, we're diving into the exciting world of continuous integration and continuous delivery (CI/CD), and we're kicking things off by shining a spotlight on one of the most pivota...

More from this blog

D

DevOps with Aakash: Unleashing DevOps Excellence

44 posts

I'm Aakash, a freelance Linux System Admin @xFusionCorp, diving deep into the world of Docker, Kubernetes, Jenkins, AWS, and more. Let's navigate AWS DevOps tech together! Connect with me for friendly chats, shared experiences, and learning moments. Follow my journey on Twitter and Linkedin for daily insights. Let's build, automate, and innovate in the exciting world of DevOps! ๐ŸŒ