Jenkins CICD with GitHub Integration

Jenkins CICD with GitHub Integration

Day 24: #90DaysOfDevOps Challange

Continuous Integration/Continuous Deployment (CI/CD) is an important aspect of modern software development. Jenkins, GitHub, and Docker are some of the most commonly used tools for CI/CD. In this blog post, we will walk you through the steps to integrate Jenkins with GitHub and use Docker Compose for deploying the application.

Step-by-Step Guide:

  1. Launch an AWS EC2 instance(jenkins-node)

  2. Login to your AWS EC2 instance and install Java Development Kit (JDK) followed by jenkins :

     sudo apt update 
    
     sudo apt install openjdk-11-jre 
    
      java -version openjdk version
    

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins

✨✨✨✨✨✨✨✨Jenkins is active and running✨✨✨✨✨✨✨✨✨

  1. By default jenkins runs on port 8080 so we need to expose port 8080 , but how?🙄Ok so click on our instance and navigate to security of our instance:

  2. Ok now click on security groups and Edit inbound rules and click on add rule

    1. Select custom TCP and port range as 8080 and source as my IP

6. Now we can access jenkins on our web browser by our IP followed by port 8080 as follow:

  1. The passwork required to access Jenkins can be accessed as follow:

  2. Click on install suggested plugins

  3. It will ask for user name and set password and jenkins is all set :

✨✨✨✨✨✨✨✨✨Ok Now lets start the real work✨✨✨✨✨✨✨✨

  1. create a new item as follow:

  2. Enter the discription and select as a git hub project and enter the URL of the project

  3. Source code management select Git and enter the git URL

  4. Select branch as master

  5. Now time for github integration with Jenkins via SSH so navigate into our console and type ssh-keygen

  6. Inside .ssh directory public and private keys are stored,for github to connect we need public key so copy that as shown:

  7. Now navigate to your github settings inside SSh keys and add new key

    and add title and paste the public key as follow:

  8. Now access is provided let's add credentials

    1. select domain as (Global credentials)

    2. kind = SSH user name and private-key

    3. id = github jenkins

    4. description = This is for GitHub and jenkins integration

    5. username = ubuntu

    6. enter private key add new and copy and paste from the .ssh directory inside the id_rsa file

    7. and save

  9. GitHub integration is done

  10. Now click on build now and navigate to the console output:

    1. inside our console navigate to workspace directory our app is ready

    2. Go to the security group of our instance edit inbound rule select port 8000 and give access to every one by selecting ipv4 protocol

  1. Now time to configure our node app so go to execute shell

  2. save and click on build now

    That's it! 🎉🎉✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨You have successfully created a Jenkins project for your Node-Todo-CICD app

Did you find this article valuable?

Support Dhananjay Kulkarni by becoming a sponsor. Any amount is appreciated!