DevOps(Day-24) : Complete Jenkins CI/CD Project

DevOps(Day-24) : Complete Jenkins CI/CD Project

TABLE OF CONTENTS

Let's make a beautiful CI/CD Pipeline for your Node JS Application.

TASK-1 : Django-todo-app

We are going to set up a pipeline for a Django application.

  1. Create a new item and choose a free-style project.

  2. In the General setting provide the project description.

  3. Now, go to Source code management to configure GitHub to Jenkins. Provide the GitHub URL where the code exists. Use the secret text option to provide credentials to Jenkins.

  4. Now, go to Build Steps and choose the execute shell build option.

    Guess, you have already written the docker file to containerize the application.

    Provide the docker commands to build an image from the docker file and build the container.

  5. Finally, click on build now to execute the project.

  6. Navigate to the URL now.

Webhook

Let's automate the build process with the integration of webhook in GitHub.

GitHub webhooks give developers the ability to integrate with the GitHub platform.

Developers can subscribe to events taking place on GitHub, for example, Push events that occur when code is pushed to a repository, and respond to the event with an action.

The response action can be anything, such as making a database entry in an external application, sending an email, triggering a deployment process, and more. Actions you can perform in response to events on GitHub are only limited by your imagination.

When a subscribed event occurs on GitHub, GitHub triggers an HTTP POST request to the defined destination. This destination is specified as an HTTP URL, which is the endpoint that is to be called whenever the event occurs. This is known as the webhook URL. The endpoint handler at the webhook URL handles the action to be performed in response to the event.

Setting up Webhook

  1. You need to have ssh_key from the server and save it in GitHub.

  2. Go to the code repository and navigate to the settings. Then provide the details in Webhook section.

    The payload URL is the Jenkins URL.

  3. It should be configured now.

    Automating Task-1 through Webhook

    1. Make changes to the file in GitHub for the project and commit it.

    2. Monitor the build in Jenkins that must have triggered automatically by webhook.

    3. Navigate to the URL to see the changes that you had made in the code in GitHub.

Task-2 : Configuring Task-1 using Docker-Compose

  1. Write a Docker Compose file for the application.

  2. Now, go to Jenkins and navigate to the build steps of the project.

  3. Now, build the project and check if the build is successfully completed. Finally navigate to the URL.

Thanks for reading my article. Have a nice day.