Day 24 Task: Complete Jenkins CI/CD Project

Day 24 Task: Complete Jenkins CI/CD Project

Setting up a CICD Pipeline for Node JS Application

Task-01

  • Fork this repository

Now, to connect GitHub repository and Jenkins. Install GitHub Integration. Connecting a GitHub repository to Jenkins can be done in several ways, and whether you need SSH keys depends on the method you choose.

SSH Key Authentication:

This method involves using SSH keys for authentication.

Generate SSH Key:

Add SSH Key to GitHub: Copy the public key (~/.ssh/id_rsa.pub ) and add it to your GitHub account under "Settings" > "SSH and GPG keys."

Jenkins Credentials: In Jenkins, create a new item and choose a free-style project.

Now, go to Source code management, and choose "Git" to configure GitHub to Jenkins. Provide a description and the GitHub URL where the code exists, and select the SSH key credential you created.

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

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

Navigate to the URL

GitHub Webhook

GitHub Webhook is a feature that allows GitHub to send HTTP POST requests to a specified URL when certain events occur in a repository. These events can include code pushes, pull requests, issues, releases, and more. Webhooks enable external services, such as Jenkins or CI/CD systems, to be notified automatically when changes or events happen in a GitHub repository.

To set up a webhook in a GitHub repository:

  1. In your GitHub repository, go to "Settings", navigate to "Webhook", and click on "Add Webhook"

  2. Provide the Payload URL: Add the Jenkins URL to the field labelled "Payload URL", then add "/github-webhook" to the end of the URL.

  3. Choose the events you want to trigger the webhook.

  4. Add the 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

  • Run the project

I'm open to receiving any suggestions, feedback, or further insights regarding the topic discussed in this article. Please share your thoughts or ideas, as I'm always open to learning.