#90DaysOfDevOps Challenge - Day 23 - Jenkins Freestyle Project for DevOps Engineers

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
Search for a command to run...

Cloud Engineer and DevOps enthusiast, just talking about AWS, Docker, Linux, Kubernetes, Python, and automation.
No comments yet. Be the first to comment.
The #90DaysOfDevOps Challenge is a dedicated initiative aimed at promoting continuous learning and skill development in the field of DevOps over a 90-day period.
Running your own home lab used to mean expensive hardware, complex networking, and hours of manual configuration. This project changes that. With a single Raspberry Pi, Docker Compose, and a few hundr

Welcome to an advanced hybrid directory demo where we'll guide you through setting up a hybrid environment, connecting to simulated on-premises infrastructure, creating a managed Microsoft AD within AWS, establishing a two-way forest trust, and integ...

Hello DevOps Community! Today marks the completion of the #90DaysOfDevOps Challenge, and it's a moment to reflect on the journey we've undertaken together. Throughout this period, I've engaged with various technologies, refining my skills in the DevO...

In a modern cloud infrastructure setup, creating a robust and scalable 2-tier architecture is essential. Such an architecture helps meet the demands of your applications while ensuring repeatability, reliability, and security. In this article, we'll ...

Welcome to Part 4 of my series on building a comprehensive CI/CD pipeline in AWS. In this article, I will explore AWS CodePipeline, a powerful service for building and deploying applications in a continuous integration and continuous delivery (CI/CD)...

Welcome to Day 23 of the #90DaysOfDevOps challenge. Today, we will dive into Jenkins freestyle projects and explore how they can be utilized by DevOps engineers to automate CI/CD processes. We will also discuss the concepts of CI/CD, build jobs, and freestyle projects. So, let's get started!

CI/CD stands for Continuous Integration and Continuous Delivery/Deployment. It is a set of practices that aim to automate and streamline the software development lifecycle. CI focuses on merging code changes frequently and automating build and test processes to catch issues early. CD extends this further by automating the delivery or deployment of applications to various environments.
In Jenkins, a build job represents a single execution of a build process. It includes tasks such as compiling code, running tests, and packaging the application. Build jobs play a vital role in CI/CD pipelines as they ensure that each code change is validated, tested, and built consistently.
Freestyle projects are a flexible and customizable project type in Jenkins. They provide a simple and intuitive way to configure and automate complex build processes. With freestyle projects, you have the freedom to define your build steps, configure triggers, and set up post-build actions according to your project's requirements.
Now, let's proceed with the resolution of the tasks for today.
Ensure the Jenkins user is added to the Docker Group to be able to run docker commands via Jenkins:

Create a new Jenkins freestyle project for your app:
In the Jenkins dashboard, click on "New Item" to create a new project.
Enter a name for your project and select "Freestyle project."
Click "OK" to proceed.
Configure the build steps:
In the Source Code Management section, I will use my GitHub Repository URL to access the Dockerfile

In the project configuration page, scroll down to the "Build" section.
Click on "Add build step" and select "Execute shell"
cd /var/lib/jenkins/workspace/90daysofdevops-day23/2023/day23/tasks
docker build . -t dockerapp:latest
echo "Image created"
Add a step to run the container:
Click on "Add build step" again and select "Execute shell."
cd /var/lib/jenkins/workspace/90daysofdevops-day23/2023/day23/tasks
docker run -d -p 3000:3000 dockerapp:latest
echo "Container is created and running"

Apply and save your project configuration.
Click on "Build Now" to start the build process and wait until the docker image is created and running on a docker container accessible from port 3000

Verify the docker container is running and access the app


Create a Jenkins project for Docker Compose:
Configure the build steps:
Scroll down to the "Build" section of the project configuration page.
Click on "Add build step" and select "Execute shell."
Enter the command "docker-compose up -d" to start the multiple containers defined in your Docker Compose file.
Click on "Build Now" to start the build process


Set up the cleanup step:
Scroll down to the "Post-build Actions" section.
Click on "Add post-build action" and select "Execute shell."
Enter the command "docker-compose down" to stop and remove the containers defined in your Docker Compose file.
Click on "Build Now" to start the build process


Congratulations! You have successfully created Jenkins freestyle projects to automate the build and deployment of your application using Docker and Docker Compose.
Jenkins, with its flexibility and wide range of integrations, provides DevOps engineers with a powerful platform to automate CI/CD processes. By leveraging the capabilities of freestyle projects, you can customize your build steps, configure triggers, and automate deployment tasks to achieve efficient and reliable software delivery.
Stay tuned for tomorrow's challenge, where we will continue exploring Jenkins with a new CI/CD Project.