Day 24: Step-by-Step Jenkins CI/CD Project Instructions

Day 24: Step-by-Step Jenkins CI/CD Project Instructions

Did you Finish Day 23?

  • Day 23 was all about Jenkins CI/CD, make sure you have done it and understood the concepts. As of today You will be doing one Project End to End and adding it to your resume :)

  • As you have worked with Docker and Docker Compose, it will be good to use it in a live project.


What is GitHub webhook?

GitHub Webhooks are a feature that allows GitHub to send HTTP POST requests to user-defined endpoints, known as webhook endpoints, in response to various events occurring within a GitHub repository. These events can include code commits, pull requests, issues, and more.

How to add a GitHub webhook?

Here are some steps to add Webhook to your Jenkins.

  • Open the GitHub repository.

  • Go to “settings” and then to “hooks”.

  • Click the “Add webhook” button.

  • Fill out the form as shown in the image below. Provide the URL of Jenkins in the webhook and add github-webhook/ at the end. You can disable SSL verifications if you don't have valid SSL for your Jenkins server. Then you can choose option "Calling the webhook only for push events" (depending on your purpose of using the webhook)


Task 01

Let's make a beautiful CI/CD project for your Node JS Application 😍

Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.

Make sure you have a CI/CD setup

steps:

  • Start with setting up your Jenkins by installing Java and Jenkins in your system as you did on day 23 and day 22.

  • Make sure you install docker as well.

  • make sure you have a project on GitHub.

  • Access your Jenkins server, and click on Create a job.

  • Give a name for your project and select freestyle from the below options.

  • Add a description for your freestyle project, select it as a GitHub project and paste the URL of your project on GitHub.

  • Select Git from the source management. Paste the repository URL and make sure the branch you select in Jenkins matches the branch of the project in GitHub.

  • Then make sure to select the GitHub hook trigger for connection with the GitHub webhook

  • Then go to the GitHub repository to add webhook.

  • Then write the execute shell script for your project.

  • Click on Save and Then Build Now to check whether your app is working or not.

  • Check in the build history, if there is a green sign means your app is running and if there is a red sign there is an error in your code.

  • Congrats, your code and application are up and running. You can check your application by running it on the browser.

  • Because you add the GitHub webhook on your Jenkins server. You will not need to click on Build Now. If any change happens in the code (GitHub), the build will be started automatically because of the GitHub webhook.


Task 02

In the Execute shell run the application using Docker compose

You will have to make a Docker Compose file for this Project (Can be a good open-source contribution)

steps:

  • Now, we will be using docker-compose instead of docker build and docker run.

  • Click on configure, and go to execute shell.

  • Write the docker-compose command as you read about docker-compose in previous days. So, it's time to implement this.

  • Click on Save and Build Now to run your application through the docker-compose.

  • Finally, you deliver the application with docker-compose. You can check your result in the Console Output.

  • Simple as that.


<That's all for today. Hope you like it. FOLLOW to join me in the journey of DevOps>