Beginners — How to integrate GitHub project with Jenkins (CI/CD)?

Uttam Pasare
Javarevisited
Published in
4 min readNov 1, 2023

CI/CD processes are very popular now a days for faster development and faster delivery of software product with no or minimal errors. 💻

Continuous Integration (CI) — is an automated software development practice for finding bugs quickly, improves quality of code and making code integration easier while working with multiple teams committing code to the same repositories. Jenkins is one of the popular tool used for integration.

Continuous Delivery (CD) — is a process where automated integration and regression tests are run on the final code to ensure existing functionality is not broken and error free software is delivered quickly with less impact.

This article is broadly divided into three categories,

  1. Setting up repository into GitHub
  2. Starting Jenkins locally
  3. Configure Jenkins to trigger manual build by connecting to GitHub

To understand this in better way we would need to create a git repository where we will commit/push the changes and we will use it under Jenkins to trigger the build. Jenkins support multiple configurations to trigger the build either automatically once commit happens to the source repository or manually or with certain interval, it is up to us how we want to configure it.

Setting up repository into GitHub

Go to GitHub and create a new repository with name of your choice e.g “jenkins-integration”

Later push simple spring-boot maven project to above repository (you can use spring initialize to generate sample project — https://start.spring.io/)

Starting Jenkins locally

You can follow below steps to start Jenkins locally,

  1. Got o Jenkins portal (https://www.jenkins.io/download/) and download Jenkins.war file
  2. Copy war file to folder of your choice e.g., “%USER%\Jenkins”

3. Later run following command to start the Jenkins locally

java -jar jenkins.war ( to run with default 8080 port)
java -jar jenkins.war — httpPort=9090 ( to run with custom port)

Configure Jenkins to trigger manual build by connecting to GitHub

let us create a maven project from Jenkins portal as below,

enter project name and select maven project from available list

In order to connect Jenkins with git we need to copy project url and checkout url from GitHub portal,

Got to “Source Code Management” section to add git checkout url

Specify maven path under “Pre Steps” ( If maven is not available to select then kindly follow next steps )

  1. Go to “Plugins” section to check if maven plugin is available under “Installed Plugins”, if not search and install

2. Under “Tools” section visit Maven Installations to configure maven. Download and unzip apache-maven at local directory and specify path under MAVEN_HOME section.

Once all above steps are done then “Save” all the changes.

Great 🥳 You are ready to go!!!!!, you are almost done with the required configurations and ready to start your first Jenkins build 😊

Visit “Dashboard” section and look for project configured with above steps and say “Build Now”

Once build is done, we can see that project is checked out from the git repository and it is successful. 🥳

Thank you for going through the article! Happy learning!!

You can download sample project from GitHub — https://github.com/uttam-pasare/jenkins-integration.git

Follow Uttam Pasare on LinkedIn for more :)

--

--

Uttam Pasare
Javarevisited

Hello, This is Uttam Pasare working as a Java Professional, love to explore, learn & share knowledge around software technologies.