Day 24 Task: Complete Jenkins CI/CD Project

Day 24 Task: Complete Jenkins CI/CD Project

Β·

3 min read

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

Task-01 & Task-02

  • Fork this repository Link

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

  • Create GitHub WebHooks and make sure you have CICD setup

  1. open your AWS console and connect to your Jenkins server

  2. click on the new item and Enter the item name "node-todo-app" and click on freestyle project and click on OK and your configuration will open

  3. And Write the description "This is node js todo app" and click on the GitHub project and past the GitHub repository URL https://github.com/nallabellisriparthu/node-todo-cicd

  4. Come to Source Code Management and click on Git and past the repository URL https://github.com/nallabellisriparthu/node-todo-cicd.git

  5. Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration for that go to your local machine and write the command

  1. After that use this command to get the private key and public key to connect GitHub to Jenkins

  1. my private key is id_rsa to see that file use this command

  1. my public key is id_rsa.pub to see that file use this command

  1. if I have to connect GitHub to my server which one would I recommend is a public key

  2. So open your GitHub and click on the settings and there you will see SSH and GPG keys and click on the new SSH key and write the title "Jenkins-project"

  3. Copy your public key and past on the key and click on add SSH key

  1. Come to your Jenkins server in Source Code Management click on +Add and select Jenkins and In kind select SSH Username with private key and in ID write github-jenkins and write the description "this is for Jenkins and github integration" and in the username write ubuntu and in private key click on Enter directly and click on Add and past your private key and at last click on add and in credential select your "ubuntu (this is for Jenkins and github integration)" and make sure that github branch and Jenkins branch should be same

  2. After that go to build steps and select execute shell and write these commands

  echo "Code Cloned"
  docker build . -t node-app

  echo "Code built..!!"
  docker-compose down
  docker-compose up -d
  echo "Container is up"
  1. Now click on build now for the execution and see the build is successful and the project is running

  • Let's understand how to setup a webhook

  • go to your node-todo-repository and click on settings there you will see webhook click on it and click on add webhook and in paylode URL write like this "ipv4:8080/github-webhook" and click on send me everything and click on add webhook and refresh the page and you will see like this

  • now if you change anything in GitHub it will built in Jenkins server


Happy Learning

Thanks For Reading! :)

-SriparthuπŸ’

Β