Day 23 - Navigating Jenkins Freestyle Projects ๐Ÿš€ โœจ

Nilkanth MistryNilkanth Mistry
3 min read

Today's challenge is particularly exciting as it entails creating a Jenkins Freestyle Project! ๐Ÿ› ๏ธโœจ DevOps enthusiasts, are you ready to unleash your creativity and automation skills? Let's make it happen! ๐Ÿ˜

Understanding CI/CD:

CI/CD: A Journey of Continuous Improvement

Continuous Integration (CI): CI automates code integration from multiple developers into a single codebase. ๐Ÿ”„ Frequent commits trigger automated tools for building, reviewing, and improving software quality. It's like having a team of robots streamlining your code collaboration! ๐Ÿค–๐Ÿ”„

Continuous Delivery (CD): After CI, CD ensures error-free, quick releases. ๐Ÿš€ It automates testing and deployment in staging, guaranteeing a release-ready product for deployment anytime. Your code's journey from creation to deployment becomes a smooth, automated dance! ๐Ÿ’ƒ๐Ÿšข

The Build Job:

In Jenkins, a build job automates specific tasks in the application building process, such as dependency gathering, compiling, testing, and deploying. ๐Ÿ—๏ธ๐Ÿ’ป Let Jenkins be your code-building assistant, taking care of the nitty-gritty tasks! ๐Ÿค–๐Ÿ’ผ

Exploring Freestyle Projects:

A freestyle project in Jenkins is a versatile option for building, testing, and deploying software. Let's walk through two exciting tasks:

Task-01: Building Docker Image for Your App:

  1. ๐Ÿ—๏ธ Create an agent for your app (previously deployed via Docker).

    • Click on "Set up an agent"

  • Give Node name, click on Permanent Agent, and click on Create.

  • Provide remote root directory location give labels to this node and select "Use WebSocket".

  • Click on save to create an agent and now the agent is created.

  1. ๐Ÿ†• Set up a new Jenkins freestyle project.

    • In the build steps, select "Execute Shell" and add a few commands and now apply and click save.

  1. In the "Build" section, add a step to run "docker build" for image creation. Witness the magic of your code transforming into a containerized masterpiece! ๐Ÿช„๐Ÿณ

  2. Add another step to run "docker run" for starting a container using the created image. Watch your app come to life in a Docker container spectacle! ๐Ÿš€๐Ÿ 

    • Check on the environment

    • Now check whether build is working, before that we should see whether port 8000 is exposed. (here in task: http://18.118.28.103:8000/todos/

Task-02: Managing Multiple Containers with Docker-Compose:

  1. ๐Ÿšข Create a Jenkins project to execute "docker-compose up -d" for starting containers (use the day-19 Docker-Compose file).
  • 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. Step 1: Create a New Jenkins ProjectLog in to your Jenkins dashboard.Click on "New Item" to create a new project.Enter a name for your project, choose "Freestyle project," and click "OK."

  • Under "General," you can provide a project description.

  • Under "Source Code Management," select the appropriate option if you're using version control.

  1. Implement a cleanup step to run "docker-compose down" for stopping and removing defined containers. It's like orchestrating a container symphony! ๐ŸŽต๐Ÿšข

In the "Build" section, click "Add build step" and choose "Execute shell."

In the shell command box, enter the following command to start the containers using Docker Compose:

 echo "code cloned"
 docker-compose down
 docker-compose up -d --no-deps --build web
 echo "code deploy"

  1. Click "Save" to save your Jenkins project configuration.

  2. You can manually run the project by clicking "Build Now" or wait for the configured triggers to initiate the build.

You have successfully created a freestyle Jenkins project !! we explore more on Jenkins in the next articles....

0
Subscribe to my newsletter

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

Written by

Nilkanth Mistry
Nilkanth Mistry

Embark on a 90-day DevOps journey with me as we tackle challenges, unravel complexities, and conquer the world of seamless software delivery. Join my Hashnode blog series where we'll explore hands-on DevOps scenarios, troubleshooting real-world issues, and mastering the art of efficient deployment. Let's embrace the challenges and elevate our DevOps expertise together! #DevOpsChallenges #HandsOnLearning #ContinuousImprovement