Day 23 Task: Jenkins Freestyle Project for DevOps Engineers.πŸ”„πŸ€–πŸ‘©β€πŸ’»

Anusha Nayak Anusha Nayak
6 min read

What is CI/CD?πŸ”„πŸš€

  1. Continuous Integration (CI):

    • What it is: Continuous Integration is the practice of frequently integrating code changes from multiple contributors into a shared repository. Each integration triggers an automated build and test process to identify and address issues early in the development cycle.🀝

    • Why it's important: CI helps prevent integration problems by catching errors quickly, ensuring that the codebase remains stable and ready for deployment at any time.πŸš¨πŸ—οΈ

  2. Continuous Delivery (CD):

    • What it is: Continuous Delivery is the practice of ensuring that code changes are always in a deployable state. This involves automating the entire software delivery process, from building and testing to deployment, in a way that allows for manual approval before releasing to production.πŸš€

    • Why it's important: CD ensures that your software is always ready for deployment, reducing the time and effort required to release new features or bug fixes.β©πŸ”„

  3. Continuous Deployment (CD):

    • What it is: Continuous Deployment is an extension of Continuous Delivery where every code change that passes automated testing is automatically deployed to the production environment without manual intervention.πŸš€πŸŽ‰

    • Why it's important: CD takes automation to the next level, allowing for faster and more frequent releases. It streamlines the delivery process and ensures that valuable features and fixes reach users quickly.⚑🌐

Key Benefits:πŸ—οΈπŸ“ˆ

  • Less Issues: Catching and fixing problems early. πŸ§‘β€πŸ”§

  • Faster Releases: Quicker delivery of new features. πŸš€

  • Reliable Deployments: Consistent and error-free releases. πŸ› οΈ

  • Better Collaboration: Improved teamwork among developers. 🀝

  • Early Bug Detection: Identifying and fixing bugs promptly. 🐞

  • Quick Feedback: Rapid response to the impact of code changes. πŸ“©

What are the principles of CI/CD?πŸ”„πŸ“¦

  1. Frequent Code IntegrationπŸ”„:

    • Developers regularly integrate their code changes into a shared repository to ensure that the codebase is continuously updated and works well together.
  2. Automated BuildsπŸ€–πŸ—οΈ:

    • The integration process triggers automated builds, compiling the code and creating executable artifacts to ensure consistency and reliability in the build process.
  3. Automated TestingπŸ€–πŸ§ͺ:

    • Automated tests are run on the integrated code to quickly identify and address errors, ensuring that the code remains functional and bug-free.
  4. Continuous FeedbackπŸ“©:

    • Developers receive quick feedback on the success or failure of their code changes, allowing for rapid identification and resolution of issues.
  5. Deployment ReadinessπŸš€:

    • Every code change is maintained in a deployable state, ensuring that the software is always ready for deployment.
  6. Automated DeploymentπŸš€πŸ€–:

    • The entire software delivery process, from building and testing to deployment, is automated to ensure consistency and reduce manual errors.
  7. Configuration as CodeπŸ§°πŸ’»:

    • Infrastructure and configuration are managed as code, making the deployment process more predictable and reproducible.
  8. Environment Parity🌐:

    • Development, testing, and production environments are kept as similar as possible, reducing the likelihood of deployment issues due to environmental differences.
  9. Collaboration and CommunicationπŸ€πŸ’¬:

    • Foster collaboration and communication among development, testing, and operations teams to ensure a smooth and efficient workflow.
  10. Version ControlπŸ“šπŸ”„:

    • Code changes are tracked using version control systems (e.g., Git), providing a history of modifications and enabling easy collaboration among team members.
  11. Manual Approval (in CD)πŸ€šπŸ‘:

    • Before releasing to production, there is an option for manual approval. This step ensures that stakeholders have an opportunity to review and authorize the deployment.
  12. Rollback Mechanism (in CD)β†©οΈπŸ”„:

    • A reliable rollback mechanism is in place in case any issues are detected post-deployment, ensuring quick recovery from unexpected problems.

How does CI/CD work?πŸ€–πŸ‘©β€πŸ’»πŸš€

  1. Code Changes Trigger πŸš€:

    When a developer makes changes to the code and pushes it to a shared space (like Git), it's like raising a flag saying, "Hey, I've got something new!"

  2. Automated Build and Test πŸ› οΈπŸ§ͺ:

    A smart robot (automation) takes the code changes, builds them like constructing a Lego tower, and tests them to make sure everything fits together without errors.

  3. Deploy Readiness Check 🚦:

    The system checks if the code changes are ready for deployment, making sure everything is in order like packing a suitcase for a trip.

  4. Automatic Deployment 🚚:

    If everything looks good, another automation takes over and deploys the code changes to where it needs to go, like a magical delivery service making sure the package reaches its destination.

What Is a Build Job?πŸ—οΈ

A Build Job is like a special task assigned to a helpful robot in our team. πŸ€– Its main job is to take the code we've written and put it together in a way that's super organized.

When we tell the robot to start the Build Job, it takes all our code and carefully arranges it, making sure everything fits perfectly. Think of it as organizing a messy room into a neat and tidy space. Once it's done, we have a neat package ready to use.πŸ“¦βœ¨

The Build Job is crucial because it helps us find and fix any issues in our code early on. It's like having a diligent assistant who ensures everything is in order before we move on to the next steps in our project.πŸ•΅οΈβ€β™‚οΈπŸ‘

What is Freestyle Projects?πŸ”„πŸ› οΈ

"Freestyle Project" refers to a type of project configuration that provides a flexible and easy-to-use way to define and execute tasks in JenkinsπŸ› οΈ. It allows users to create jobs or projects using a graphical user interface without the need for scripting or coding knowledge.

Freestyle Projects are user-friendly and suitable for simpler automation needs. They are accessible for users who may not have advanced scripting skills. However, for more complex or scripted workflows, Jenkins provides other project types like πŸš€Pipeline Projects, which allow you to define your πŸ€–automation process using code (typically written in Groovy scripting language).

TasksπŸ“‹πŸ€–

Task-01

- Create a agent for your app.

Use ssh method to create agent node

- 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.

- 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.

πŸ™Œ Thank you for taking the time to explore this blog!πŸ“š I hope you found the information both helpful and insightful.✨

πŸš€ Enjoy your learning journey, and don't hesitate to reach out if you have any feedback. πŸ€“ Happy exploring!

10
Subscribe to my newsletter

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

Written by

Anusha Nayak
Anusha Nayak

Hi everyone, I am Anusha Nayak. πŸš€I am passionate about bridging the realms of development and operations to propel efficient and seamless software delivery! πŸ’» As a DevOps professional, I'm all about making things run smoother, like cutting out unnecessary steps, setting up automatic software installations, and making sure everything flows together nicelyπŸ‘¨β€πŸ’». I want to help teams create great software quickly every single time.