Day 25 Task: Complete Jenkins CI/CD Project Continued with Documentation
Hello everyone I am back with a new DevOps task.
I can imagine catching up will be tough so take a small breather today and complete the Jenkins CI/CD project from Day 24 and add a documentation.
Did you finish Day 24?
Day 24 will give you an End to End project and adding it to your resume will be a cherry on the top.
take more time, finish the project, add a Documentation, add it to your Resume and post about it today.
Here is the today’s tasks:
Document the process from cloning the repository to adding webhooks, and Deployment, etc. as a README .
A well written readme file will help others to understand your project and you will understand how to use the project again without any problems.
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 -d --build
Save the project.
Install GitHub integration plugin via manage plugin.
Test the application via modifying the GitHub repo code.