Day 24 Task: Complete Jenkins CI/CD Project

Day 24 Task: Complete Jenkins CI/CD Project

We have you finished Day 23 task

  • Day 23 was all about Jenkins CI/CD, make sure you have done it and understood the concepts. As today You will be doing one Project End to End and adding it to your resume :)

  • As you have worked with Docker and Docker compose, it will be good to use it in a live project.


Task-01

  • Fork this repository which of TrainWithShubham github repository from there just fork node-todo-cicd

  • Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.

  • Read About GitHub WebHooks and make sure you have CICD setup

  • Refer this video for the entire project

Before starting this task lets check what is webhook actually and how it works

Webhooks allow you to build or set up integrations, such as GitHub Apps or OAuth Apps, which subscribe to certain events on GitHub.com. When one of those events is triggered, we'll send a HTTP POST payload to the webhook's configured URL. Webhooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. You're only limited by your imagination.

Webhooks can be installed on an organization, a specific repository, or a GitHub App. Once installed, the webhook will be sent each time one or more subscribed events occurs.

Events

When configuring a webhook, you can use the UI or API to choose which events will send you payloads. Only subscribing to the specific events you plan on handling limits the number of HTTP requests to your server. You can also subscribe to all current and future events. By default, webhooks are only subscribed to the push event. You can change the list of subscribed events anytime.

Each event corresponds to a certain set of actions that can happen to your organization and/or repository. For example, if you subscribe to the issues event you'll receive detailed payloads every time an issue is opened, closed, labeled, etc.

Prerequisite for this task 01

Please follow the Day 22 task blog. In this blog, you will see how to connect Jenkins to a server.

Step1: Fork this repository by following steps

Step2: In Jenkins select GitHub project and copy the fork repository URL like this

Then paste it in Jenkins GitHub project section like this

Step 4: In the Source Code Management select Git and copy the repository HTTP URL like this

and paste it in the Source Code Management section and set the Branch Specifier to master like this and you no need add credentials here because it public repository.

Step 5: In build section select Execute shell and run some basic commands like this and save it

Step 6: Click on Build Now

step 7: You can it runing and click there

then you will be directed to this page and now click on the console output

Step 8: Now you see this page and we successfully connected the GitHub repository to the server Jenkins as you can see. Do one thing to confirm just copy this directory in the top as shown in the image

Step 9: Go to the server terminal ad run these commands

cd /var/lib/jenkins/workspace/node-todo-app-deploy

and then run this command

ls

Now you can see all the repository files are on the server. So that how we completed task 01.


Task-02

  • In the Execute shell run the application using Docker compose

  • You will have to make a Docker Compose file for this Project (Can be a good open source contribution)

  • Run the project and give yourself a treat:)

step 1: You need to install docker-compose in the server

sudo apt-get install docker-compose

Step 2: Give permission to Jenkins and reboot the server and reboot your Jenkins as well like this

Step 3: Go to configure

Step 5: In the Build steps run these commands and click save

docker-compose down
docker-compose up -d

Step 6: In instance, security group add 8000 port because we have added port 8000 in docker-compose.ymal file

Step 7: Now click on Build now

you can see its running and click on it

and go to console output you see this

Step 8: Now go to instance IP address

Copy and paste it into google chrome and add ":8000" at the end of the IP address to it like this

Now you see this page and also we have completed our task 02 as well which deploy the node todo app through docker-compose in Jenkins


Thank you for reading this blog and if any queries or if any corrections to be done in this blog please let me know.

contact us in Linkedin ,Twitter or email-id