Day 23 Task: Jenkins Freestyle Project for DevOps Engineers - 90DaysOfDevOps

Day 23 Task: Jenkins Freestyle Project for DevOps Engineers - 90DaysOfDevOps

ยท

4 min read

The community is crushing it in the #90daysofdevops journey. Today's challenge is particularly exciting as it entails creating a Jenkins Freestyle Project, an opportunity for DevOps engineers to showcase their skills and push their limits. Who's ready to dive in and make it happen? ๐Ÿ˜

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 into 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. Here are a few tasks that you could complete when working with a freestyle project in Jenkins:

Task-01

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

    Steps to install Jenkins agent on Ubuntu -

    a. First, we need to install Java on our machine -

     sudo apt update
     sudo apt install openjdk-17-jre
     java --version
    

     curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
       /usr/share/keyrings/jenkins-keyring.asc > /dev/null
     echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
       https://pkg.jenkins.io/debian binary/ | sudo tee \
       /etc/apt/sources.list.d/jenkins.list > /dev/null
     sudo apt-get update
     sudo apt-get install jenkins
    

    b. Validate the Jenkins service using systemctl command -

    c. Jenkins runs on port 8080, make sure the port is open in the security group of the EC2 instance.

    d. Setup the Jenkins web UI following the steps

  1. Create a new Jenkins freestyle project for your app.

  2. In the "Build" section of the project, add a build step to run the "docker build" command to build the image for the container.

    Note: Make sure the user Jenkins has permission to run docker commands

  3. Add a second step to run the "docker run" command to start a container using the image created in step 3.

  1. Build it in Jenkins -

    We can see the logs under the console output of any particular build.

Task-02

  • Create Jenkins project to run the "docker-compose up -d" command to start the multiple containers defined in the compose file (Hint- use day-19 Application & Database docker-compose file)

    The build was completed successfully.

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

    Couldn't take a screenshot of docker-compose down as the server went unresponsive due to high resource utilization. We were running on t2.micro and ran multiple containers together. To avoid this, we can use t2.medium or higher.

ย