How to Integrate GitHub with Jenkins CI/CD Pipeline on Debian 12 Bookworm System
Categories:
4 minute read
In the world of modern software development, Continuous Integration and Continuous Deployment (CI/CD) are critical practices for delivering quality applications quickly and reliably. Jenkins, an open-source automation server, is a powerful tool to build and automate CI/CD pipelines. When paired with GitHub, it enables developers to automate builds, run tests, and deploy code seamlessly.
In this post, we’ll walk you through the process of integrating GitHub with Jenkins on a Debian 12 “Bookworm” system, creating a robust and flexible CI/CD pipeline.
1. Introduction to Jenkins and GitHub Integration
Jenkins enables developers to automate the build-test-deploy process. By integrating Jenkins with GitHub, code pushed to a repository can automatically trigger Jenkins jobs—building, testing, and even deploying the application without manual intervention.
This saves time, reduces human error, and promotes agile development.
2. Prerequisites
Before diving in, ensure the following:
- You have a Debian 12 “Bookworm” system with sudo privileges.
- A GitHub account and a repository to work with.
- A basic understanding of Git and Jenkins.
- Internet access on the Debian system.
3. Step 1: Installing Java on Debian 12
Jenkins requires Java to run. Debian 12 supports OpenJDK 17 by default.
Install Java
sudo apt update
sudo apt install openjdk-17-jdk -y
Verify the installation
java -version
You should see something like:
openjdk version "17.0.x"
4. Step 2: Installing Jenkins
Jenkins is not available by default in Debian repositories. We’ll use the official Jenkins repository.
Add Jenkins Repository
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.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-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
Install Jenkins
sudo apt update
sudo apt install jenkins -y
Start and Enable Jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
5. Step 3: Configuring Jenkins for First Use
Access Jenkins
Open your browser and navigate to:
http://your_server_ip_or_domain:8080
Unlock Jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Paste this password into the setup page.
Install Plugins
Choose “Install suggested plugins.”
Create Admin User
Fill in the required fields to create your admin user.
6. Step 4: Installing Git and GitHub Plugin
To work with GitHub repositories, install Git and necessary Jenkins plugins.
Install Git
sudo apt install git -y
Install GitHub Plugin in Jenkins
- Go to: Manage Jenkins > Plugins
- Search for and install:
- GitHub Integration Plugin
- Git Plugin
- Pipeline
- GitHub Branch Source
Restart Jenkins if prompted.
7. Step 5: Generating and Adding SSH Keys
To allow Jenkins to access private GitHub repositories, use SSH keys.
Generate SSH Key as Jenkins User
sudo -u jenkins ssh-keygen -t rsa -b 4096 -C "jenkins@yourdomain.com"
Leave passphrase empty. This generates keys in /var/lib/jenkins/.ssh/id_rsa
.
Add Public Key to GitHub
- Copy the key:
sudo cat /var/lib/jenkins/.ssh/id_rsa.pub
- On GitHub:
- Go to Settings > SSH and GPG keys > New SSH key
- Paste the public key
8. Step 6: Connecting Jenkins to GitHub
In Jenkins:
- Navigate to Manage Jenkins > Configure System
- Under GitHub, click Add GitHub Server
- Provide a name and credentials (use SSH or personal access token)
- Test the connection
Alternatively, use a GitHub personal access token:
- Go to GitHub > Settings > Developer settings > Tokens
- Create a token with repo and workflow permissions
- Add it in Jenkins credentials
9. Step 7: Creating a Simple Jenkins Job
Let’s create a Freestyle project for this example.
Create Job
- Go to New Item > Freestyle Project
- Name it
MyGitHubCIProject
- Under Source Code Management, select Git
- Enter your repository URL (SSH or HTTPS)
- Choose credentials if necessary
Configure Build Triggers
- Check GitHub hook trigger for GITScm polling
Add Build Step
For example:
echo "Pulling latest code..."
git --version
echo "Running build steps"
Save and exit.
10. Step 8: Setting Up Webhooks on GitHub
To notify Jenkins when code is pushed:
- Go to your GitHub repository > Settings > Webhooks
- Click Add Webhook
- Payload URL:
http://your_server_ip_or_domain:8080/github-webhook/
- Content Type:
application/json
- Events: Choose “Just the push event”
- Save
Test by pushing code to the repository—Jenkins should trigger automatically.
11. Step 9: Testing the CI/CD Pipeline
Make a change in your GitHub repo:
echo "New update" >> README.md
git add README.md
git commit -m "Trigger Jenkins build"
git push
Watch Jenkins dashboard. A new build should start shortly.
View Console Output
Click the job > select the build > Console Output
You should see your build steps being executed.
12. Conclusion
Integrating GitHub with Jenkins on a Debian 12 Bookworm system is a powerful step toward building reliable CI/CD workflows. With Jenkins watching your repositories, every push becomes an opportunity to automatically build, test, and deploy code—freeing developers to focus on innovation rather than infrastructure.
This tutorial gave you a foundational setup. From here, you can:
- Add test automation frameworks
- Configure deployment scripts
- Use Jenkins Pipelines for more advanced workflows
By automating with Jenkins, you’re embracing a DevOps mindset that empowers teams to move faster with higher confidence.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.