Complete Jenkins CI/CD Project (Part-3)

Complete Jenkins CI/CD Project (Part-3)

Time to set up a CI/CD Pipeline for our Node.js Application!

We covered Jenkins CI/CD last time and grasped the concepts. Today, we're diving into a complete end-to-end project.

Given our familiarity with Docker and Docker-compose, let's leverage them in this live project. It's going to be an exciting ride!".

"Here's our typical project cycle:

  1. The source code resides on GitHub.

  2. Whenever developers make changes in the repository, our pipeline kicks off automatically (leveraging webhook functionality) for Continuous Integration.

  3. The pipeline initiates the build process and deploys the code using our docker-compose.yaml file for Continuous Deployment or Delivery.

Task 1:

Will keep our node.js (todo-app) source-code in our git hub repository.

Now we are creating a connection to Jenkins job and GitHub Repository via GitHub Integration.

Step1: Generate the SSH keys for integrating your Jenkins project with your git repository. Use ssh-keygen command to create public and private key.

Step 2: Configuring GitHub

  1. Go to your GitHub account settings.

  1. Go to SSH and GPG keys, Add public key that we created using ssh-keygen and select key-type Authentication key.

Step 3 : For GitHub-Webhook:

  1. Go to your GitHub repository and click on Settings.

  2. Click on Webhooks and then click on Add webhook.

  3. In the ‘Payload URL’ field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/. In the ‘Content type’ select: ‘application/json’ and leave the ‘Secret’ field empty.

    Now we can verify the webhook.

Task 2:

1) now we create docker-compose.yaml file through which we deploy our code. We kept yaml file in our git-hub repository.

2) Configure Jenkins pipeline as below and set build execution steps with docker-compose file.

Saved the pipeline and executed it successfully.

log

now we can see our job successfully executed and code (image) has been deployed.

We can navigate using public ip:8000

Task 3:

To test the webhook, let's make changes to our code in the GitHub repository and watch as our pipeline gets triggered automatically.

The pipeline was executed seamlessly and successfully in Jenkins without any manual intervention.

We can see changes reflected well.

The successful completion of the above task gives us confidence in deploying end-to-end projects using the Jenkins pipeline. We'll delve deeper into Jenkins pipelines in our next task to further enhance our understanding

Thanks,

Kishor Chavan