Jenkins Freestyle Project

Unnati GuptaUnnati Gupta
4 min read

#90daysdevopschallenge

#day23

What is CI/CD?

CI or Continuous Integration is the practice of automating the integration of code changes from multiple developers into a single codebase. It is a software development practice where the developers commit their work frequently to the central code repository (GitHub or Stash). Then there are automated tools that build the newly committed code and do a code review, etc as required upon integration. The key goals of Continuous Integration are to find and address bugs quicker, make the process of integrating code across a team of developers easier, improve software quality, and reduce the time it takes to release new feature updates.

CD or Continuous Delivery is carried out after Continuous Integration to make sure that we can release new changes to our customers quickly in an error-free way. This includes running integration and regression tests in the staging area (similar to the production environment) so that the final release is not broken in production. It ensures to automate the release process so that we have a release-ready product at all times and we can deploy our application at any point in time.

What Is a Build Job?

A Jenkins build job contains the configuration for automating a specific task or step in the application building process. These tasks include gathering dependencies, compiling, archiving, or transforming code, and testing and deploying code in different environments.

Jenkins supports several types of build jobs, such as freestyle projects, pipelines, multi-configuration projects, folders, multibranch pipelines, and organization folders.

What is Freestyle Projects ?? ๐Ÿค”

A freestyle project in Jenkins is a type of project that allows you to build, test, and deploy software using a variety of different options and configurations.

Task-01

  • Create an agent for your app. ( which you deployed from docker in the earlier task)

    Step1: Click on "Set up an agent"

    Step 2: Give Node name, click on Permanent Agent, and click on Create.

    Step 3: Finally Agent Created.

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

    Step 1: Click on "Create a Job".

    Step 2: Give the name of your project, Select "Freestyle Project" and Click on "OK".

    Step 3: Select "Execute Shell".

    Step 4: Put Execute Commands

      cd /home/projects/django/django_docker_project/pro1 
      docker build . -t app 
      docker run -d -p 8000:8000 app
    

    Step 5: Click on "Build Now".

    Step 6: Check Result

    Step 7: Check on the environment

Task-02

  • Create a Jenkins project to run the "docker-compose up -d" command to start the multiple containers defined in the compose file.

    Before going through this task, first, check the docker-compose install in your system.

    for installing docker-compose or detailed information about that follow this:

    https://devunnatig.hashnode.dev/docker-compose-for-devops-engineer

    Step 1: Click on "Create a Job".

    Step 2: Give the name of your project, Select "Freestyle Project" and Click on "OK".

  • Step 3: Select "Execute Shell".

    Step 4: Put Execute Commands

      cd /home/projects/docker-compose
      docker-compose up -d
      docker ps -a
    

    Step 5: Click on "Build Now".

    Step 6: Check Result

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

    Step 1: Go again on configuration and change commands

    docker-compose down

    Step 2: Click on "Build Now".

Step 3: Check Result

In the Next Article, we will explore Jenkins......

Thank you for giving your precious time to read this blog/article and if any suggestions or improvements are required on my blogs feel free to connect on LinkedIn Unnati Gupta. Happy Learning !!!

10
Subscribe to my newsletter

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

Written by

Unnati Gupta
Unnati Gupta

๐Ÿ‘จโ€๐Ÿ’ป DevOps Engineer at 6D Technology Passionate about bridging the gap between development and operations, I'm a dedicated DevOps Engineer at 6D Technology. With a strong belief in the power of automation, continuous integration, and continuous delivery, I thrive in optimizing software development pipelines for efficiency and reliability. ๐Ÿš€ Exploring the DevOps Universe In my articles, I delve into the fascinating world of DevOps, where I share insights, best practices, and real-world experiences. From containerization and orchestration to CI/CD pipelines and infrastructure as code, I'm here to demystify the complex and empower fellow developers and ops enthusiasts. ๐Ÿ“ Blogging for Knowledge Sharing As a tech enthusiast and a lifelong learner, I'm committed to sharing knowledge. My articles aim to simplify complex concepts and provide practical tips that help teams and individuals streamline their software delivery processes. ๐ŸŒ Connect with Me Let's connect and explore the ever-evolving landscape of DevOps together. Feel free to reach out, comment, or share your thoughts on my articles. Together, we can foster a culture of collaboration and innovation in the DevOps community. ๐Ÿ”— Social Links LinkedIn: https://www.linkedin.com/in/unnati-gupta-%F0%9F%87%AE%F0%9F%87%B3-a62563183/ GitHub: https://github.com/DevUnnati ๐Ÿ“ฉ Contact Have questions or looking to collaborate? You can reach me at unnatigupta527@gmail.com Happy Learning!!