Day 25 : Complete Jenkins CI/CD Project - Continued with Documentation
An awesome project to understand automation of nodejs application using webhook integration!
Getting Started
To get a local copy up and running follow these steps.
Prerequisites
- java
sudo apt install openjdk-11-jre
java --version
- nodejs
sudo apt install nodejs
sudo apt install npm
#only for current system
sudo npm install
node app.js
Installation
Install Docker
Check docker version using docker — version
Install Java Development Kit (JDK)
Set path for the Environmental variable for JDK
Download and Install Jenkins
Check the Jenkins version using jenkins — version
Check if jenkins service is running using systemctl status jenkins
Fork the repository
git fork <github_repo_url>
SSH Keys
ssh-keygen
cd .ssh
ls
SSH server connection with GitHub
Open GitHub personal account setting
Select SSH and GPG keys
Add new ssh-key
Webhook
Webhook in jenkins triggers pipeline automatically when any changes are done in github repo like commit and push.
Copy jenkins URL
Go to repo settings in github
Select Add webhook and paste URL
Append url with /github-webhook/
Continuous Deployment Using Dockerfile
Login to Jenkins with credentials say username and password
Click on new item of freestyle project
Set description for the project.
Add GitHub repository Url in GitHub project.
Add Git in Source code management.
Set credentials with SSH username and private key.
Add Build triggers say GitHub hook trigger for GITScm for webhook automation.
Add Build Steps
docker build . -t <image_tag>
docker run -d --name <container_name> -p <ext_port>:<int_port> <image_tag>
Save the project.
Install GitHub integration plugin via manage plugin.
Test the application via modifying the GitHub repo code.
Using Docker-compose.yaml file
Uncheck the GitHub trigger
Modify the docker-compose.yaml file in forked repository or create new one.
Again check GitHub trigger.
Add Build steps
docker compose down
docker-compose up --no-deps --build -d
Save the project.
Install GitHub integration plugin via manage plugin.
Test the application via modifying the GitHub repo code.
I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .
thank you : )
Subscribe to my newsletter
Read articles from Prathmesh Vibhute directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by