Table of contents
Task 1:
Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.
To generate the SHH key for integration use the shh-keygen
command for public and private keys.
To create a Public key we have to use cat /home/ubuntu/.ssh/id_
rsa.pub
To configure the GitHub Goto account setting < SHH and GPG keys and paste the ssh-rsa key here.
Click on New SSH keys
Give the desired name and paste the public keys
Click on Add SSH key and Save
Now your SSH keys has been added
Read About GitHub WebHooks and make sure you have a CICD setup.
For setting up a github webhook go to github repo's setting < Webhooks and add webhook
Click on Add Webhook
In the payload URL enter your Jenkins URL and after / write github-webhook
also change the content type to application.json
and click on add webhook
Note: Localhost URL will not work do create an ec2 instance and after that try to put the payload URL
To install GitHub integration plugins go to the Jenkins dashboard > Manage Jenkins > Plugins
Install the selected plugin
Do wait for sometime till jenkins restart
Once Jenkins is restarted. Create a new project with freestyle pipeline
add git repo for clone https://github.com/rikkkdipen/node-todo-cicd.git
click on add credentials and add
In the kind section select SSH Username with private key
Enter your Hostname and add the private key from .ssh folder on your instance
After that scroll down to build trigger section and select Git Hook trigger for SCM polling
and click save
Task 2:
- In the Execute shell run the application using Docker compose
You will have to make a Docker Compose file for this Project
Run the project and give yourself a treat
Troubleshooting
It says docker-compose not found. Since I created this new instance only for demo purpose so i didn't install docker-compose in it
we can install docker-compose with a short and simple command in the instance
sudo apt -y install docker-compose
since docker-compose is now installed on the EC2 instance. Let's try and build the project again
In brief, the GitHub-Jenkins webhook integration for CI/CD synergizes version control and automation, expediting development cycles and elevating code quality. This fusion enhances collaboration, delivering efficient and reliable application deployment. Leveraging this integration is pivotal for modern software development, enabling agile and effective practices.