We covered Jenkins CI/CD last time and grasped the concepts. Today, we're diving into a complete end-to-end project.
"Below is our Project Cycle"
The source code resides on GitHub.
Whenever developers make changes in the repository, our pipeline kicks off automatically (leveraging webhook functionality) for Continuous Integration.
The pipeline initiates the build process and deploys the code using our docker-compose.yaml file for Continuous Deployment or Delivery.
Task 1:
Kept our code node.js (to-do-app) source code in out 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
Go to your GitHub account settings.
Add ssh keys.
Step 3 : For GitHub-Webhook:
Go to your GitHub repository and click on Settings.
Click on Webhooks and then click on Add webhook.
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.
Verified 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 we have executed it successfully.
Check the logs:
now we can see our job successfully executed and code (image) has been deployed.
We can navigate using public ip:8000
Happy Learning !!