✨Day 28: Jenkins Freestyle Project for DevOps Engineers.

Ritesh DolareRitesh Dolare
4 min read

Today, I delved into the concepts of Continuous Integration (CI) and Continuous Deployment (CD), two fundamental practices that streamline the software development process. By automating code integration and deployment, CI/CD ensures that developers can deliver high-quality software efficiently and reliably. I also explored the functionalities of Jenkins, focusing on building jobs and freestyle projects, and completed practical tasks to solidify my understanding.

🚀Table of Content

✅What is CI/CD?

✅What is Build Job?

✅What is a freestyle project?

Tasks:

✅Task 1:

✅Tasks 2:

✅Conclusion:

✅ What is CI/CD?

Continuous Integration (CI) and Continuous Deployment (CD) are essential practices in modern software development. They automate the integration of code changes and their deployment to production environments, ensuring a smooth, efficient, and reliable development process.

✨ Continuous Integration (CI)

CI ensures that all developers' code changes are regularly merged into a central repository. This frequent integration helps catch and resolve conflicts and errors early, making the final product more stable and easier to maintain. Tools like Jenkins facilitate this by automatically building, testing, and reviewing the code with each integration.

✨ Continuous Delivery (CD)

CD takes CI a step further by ensuring that the integrated code is always ready to be deployed into a production-like environment. This process automates the deployment of code, allowing for quick and safe releases. Continuous Delivery ensures that every change is thoroughly tested in a staging environment, mirroring the production environment to avoid surprises.

✨ Continuous Deployment (CD)

Continuous Deployment is an extension of Continuous Delivery. It automates the entire process from code integration to deployment in production without any manual intervention. This means every change that passes the automated tests is immediately released to the customers, ensuring quick updates and fixes.

✅ What is Build Job?

In Jenkins, a build job is a critical component of the CI pipeline. It automates the process of compiling source code, running tests, and generating artifacts (useful files). Here's what a typical build job involves:

  1. Source Code Retrieval: Fetching the latest code from a version control system like Git.

  2. Build Process: Compiling the code, packaging applications, or generating documentation.

  3. Testing: Running automated tests to ensure the code quality.

  4. Artifact Generation: Creating files such as binaries or deployment packages.

  5. Notifications: Informing team members about the build status.

  6. Logging and Reporting: Keeping detailed logs of the build process for troubleshooting and improvements.

✅ What is Freestyle Project?

A Jenkins Freestyle Project is a versatile job that allows you to define a series of build steps and post-build actions. It offers flexibility to configure build triggers, security, and plugins to extend its functionality.

✅ Task 1: Create a Jenkins Project to Build and Run a Docker Container

  1. Create an Agent for Your App:

    • Ensure your Jenkins agent (machine with Docker installed) is set up.
  2. Create a New Jenkins Freestyle Project:

    • Go to the Jenkins dashboard and click "New Item."

    • Name the project (e.g., "MyAppDockerBuild") and select "Freestyle project."

  3. Configure the Build Steps:

    • Add a build step to run docker build -t myapp-image . to build the Docker image.

    • Add another step to run docker run -d --name myapp-container -p 8080:80 myapp-image to start the container.

  4. Save and Run the Build:

    • Save the configuration and trigger a build by clicking "Build Now."

✅ Task 2: Create a Jenkins Project to Manage Multiple Docker Containers Using Docker Compose

  1. Create a New Jenkins Freestyle Project:

    • Go to the Jenkins dashboard and click "New Item."

    • Name the project (e.g., "MyAppDockerCompose") and select "Freestyle project."

  2. Configure the Build Steps:

    • Add a build step to run docker-compose up -d to start the containers.
  3. Set Up Cleanup Step:

    • In the "Post-build Actions" section, add a step to run docker-compose down to stop and remove the containers.
  4. Save the Configuration and Trigger the Build:

    • Save the configuration and trigger a build by clicking "Build Now."

✅ Conclusion

Today’s learning focused on the essentials of CI/CD, the role of build jobs in Jenkins, and the flexibility of freestyle projects. Task 1 involved creating a Jenkins project to build and run a Docker container, while Task 2 focused on managing multiple Docker containers using Docker Compose. These tasks highlighted the practical application of CI/CD principles, enhancing my understanding of automated software development and deployment.

Happy Learning! 😊

1
Subscribe to my newsletter

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

Written by

Ritesh Dolare
Ritesh Dolare

👋 Hi, I'm Ritesh Dolare, a DevOps enthusiast dedicated to mastering the art of DevOps.