Table of contents
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
open your AWS console and connect to your Jenkins server
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
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
Come to Source Code Management and click on Git and past the repository URL https://github.com/nallabellisriparthu/node-todo-cicd.git
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
- After that use this command to get the private key and public key to connect GitHub to Jenkins
- my private key is id_rsa to see that file use this command
- my public key is id_rsa.pub to see that file use this command
if I have to connect GitHub to my server which one would I recommend is a public key
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"
Copy your public key and past on the key and click on add SSH key
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
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"
- 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π