Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • jQuery
  • AngularJS
  • ReactJS
  • Next.js
  • React Native
  • NodeJS
  • Express.js
  • MongoDB
  • MERN Stack
  • PHP
  • WordPress
  • Bootstrap
  • Tailwind
  • CSS Frameworks
  • JS Frameworks
  • Web Development
Open In App
Next Article:
Jenkins and GIT Integration using SSH Key
Next article icon

Jenkins and GIT Integration using SSH Key

Last Updated : 04 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Integrating Jenkins with Git using SSH keys is a powerful way to automate your Continuous Integration (CI) and Continuous Deployment (CD) pipelines while ensuring secure access to your Git repositories. In this article, we'll guide you through the process of setting up Jenkins to work seamlessly with Git repositories using SSH keys.

Prerequisites

  • Git
  • Jenkins
  • Github

Jenkins is an open-source automation tool with built-in plugins for continuous integration purposes. It is used to build compile and test your project which makes developers work easy to make changes in the project. Integrating Jenkins and Git is very important if your project is on Git and you want to build it on Jenkins.

Steps to Integrate Git in Jenkins


Step 1: Click on Manage Jenkins

Step 2: Click on Global Tool Configuration

Step 3: Set your git home location i.e. give the path of git in your system

Step 4: Now that you have linked your local git with your local Jenkins. It is time to generate the SSH keys for integrating your Jenkins project with your git repository. Open your git bash and type the command

ssh-keygen

It will generate two files in .ssh folder. One is id_rsa which is the private key and the other file is id_rsa.pub

Step 5: Now go to GitHub and login with your account. Then go to settings and select the SSH and GPG keys and then click on the button New SSH Key.


Step 6: Now you have to paste the public key here which you generated and is saved in .ssh folder under the file name id_rsa.pub. Copy the whole key and paste it in git and save it there.

Adding Credentials

Add Credentials option.

Step 1: Click on the System

Step 2: Select the Global Credentials

Step 3: Then click on Add Credentials

Step 4: Select the Kind dropdown as SSH Username with Private Key and configure it. Configure the private key here which is stored in .ssh folder under the file name id_rsa.

Configuring Git with Jenkins

Now you have configured both the private and public key in Jenkins and Github respectively. Now open your project and go to configure.

Step 1: In General check the Github project and provide your Github home URL there

Step 2: Give the repository Url in Source Code Management, repository Url can be fetched by clicking on clone and download option of Github and you have to select the SSH Url. Also, add credentials there of Jenkins. Just like this image.

Step 3: Lastly set your pom.xml path if it is a maven project and click on apply and save The pom.xml will be the path of your project repository. Like if you have multiple repositories in you Github then your formal to write your pom.xml should be like this "Repo_name\pom.xml".

Now You are all set to clone the git repositories in your Jenkins. Just go to your project and select.


Next Article
Jenkins and GIT Integration using SSH Key

T

TUSHAR1
Improve
Article Tags :
  • Web Technologies
  • Git
  • DevOps
  • Jenkins

Similar Reads

    How To Set Up Continuous Integration With Git and Jenkins?
    Continuous Integration (CI) is a practice where developers integrate their code into a shared repository frequently, ideally several times a day. Each integration can then be verified by an automated build and automated tests. This practice helps to detect errors quickly and improve software quality
    4 min read
    Integrating Jenkins With Popular GitHub
    When you push the code into GitHub, you have to manually trigger builds and assessments every time. It's like building a sandcastle one grain at a time. This can be time-consuming and inefficient. Fortunately, Jenkins and GitHub are a dynamic pair that can take you to a world of computerized continu
    8 min read
    Jenkins Interview Questions and Answer
    Jenkins is a popular open-source automation tool used for setting up Continuous Integration (CI) and Continuous Delivery (CD) pipelines. It helps developers automate tasks like building, testing, and deploying software, making it an essential tool for DevOps. Jenkins is known for its flexibility, sc
    15+ min read
    How To Integrate Jenkins With Slack ?
    In the present high-speed software development scene, consistent communication and collaboration efforts among teams are foremost. Jenkins, a software automation server, remains as a foundation for automating different undertakings across the product improvement lifecycle. Then again, Slack, a broad
    8 min read
    Integrating Ansible with GitHub for CI/CD Pipelines
    Many development teams face challenges when successfully combining several tools to form proper and effective CI/CD processes. An inefficient workflow means projects slow down, vary in their implementation, and have more overhead related to infrastructure management. Another consequence is that, due
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences