Jenkins (CI) Pipeline Setup
Speed and reliability are critical in modern software development.
In this guide, you will integrate Jenkins running on your Ubuntu 20.04 server with GitHub and set up a CI pipeline that runs automatic tests with every code submission.
Thanks to Docker containers, tests run in isolation and environment differences are eliminated.
What Will You Learn in This Guide?
- Giving Docker permission to Jenkins server
- Set up Token and Webhook between GitHub and Jenkins
- Defining the CI process as code with Jenkinsfile
- Triggering automatic tests with GitHub push actions
Prerequisites
Before you start, you should have the following ready:
- Server: Ubuntu 20.04, at least 1 GB RAM (ex: GenixNode VDS)
- Software: Jenkins (SSL configured), Nginx and Docker
- Account: GitHub account
1. Granting Docker Privilege to Jenkins User
We must authorize Jenkins to run Docker containers.
sudo usermod -aG docker jenkins
- This command adds the Jenkins user to the Docker group.
Verify authorization:
grep docker /etc/group
- Restart Jenkins for the changes to take effect:
sudo systemctl restart jenkins
Note: From the Jenkins panel, in the Manage Jenkins → Manage Plugins section
- Make sure Docker and Docker Pipeline plugins are installed.
2. Creating a GitHub Personal Access Token (PAT)
An access key is required for Jenkins to monitor your GitHub repository.
- Follow this path on GitHub:
-
Settings → Developer settings → Personal access tokens
-
When creating a token, grant these permissions:
-
repo:status
-
repo:public_repo
-
admin:org_hook
-
Copy the token as soon as you create it. It cannot be viewed later.
3. Defining GitHub Token to Jenkins
- Follow this path in the Jenkins panel:
- Manage Jenkins → Manage Credentials → (global) → Add Credentials
Fill in the fields as follows:
-
Kind: Secret text
-
Secret: GitHub token
-
Description: GitHub CI Token
Save.
Then:
-
Manage Jenkins → Configure System → GitHub
-
Add new GitHub Server
-
Select token as Credential
-
Verify with test connection
- Preparing the Sample Project
-
We use a ready-made Node.js project to test the CI process.
-
Fork the following project to your own GitHub account:
http//github.com/content-demo/hello-hapi
- This project contains a Jenkinsfile.
5. Jenkinsfile Structure
pipeline {
agent {
docker {
image 'node'
args '-u root'
}
}
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}
- This structure:
-
Runs tests in Docker
-
Jenkins isolates the host server
-
Conforms to CI standards
6. Creating a Jenkins Pipeline
- On the Jenkins main screen:
- New Item → Pipeline
Settings:
-
GitHub project: Repo URL
-
Build Trigger GitHub hook trigger
-
Pipeline Definition: Pipeline script from SCM
-
SCM: Go
-
Repository URL: Forked repo
-
Save.
7. First Build and Webhook Creation
For automatic addition of the webhook, the first build is started manually.
On the Pipeline screen:
- Build Now
After the build is completed, go to GitHub → Settings → Webhooks
You will see the Jenkins webhook created.
8. Testing Auto Trigger
-
Make a small change in the GitHub repo and commit it.
-
You will see a new build starting automatically in the Jenkins panel.
-
Your CI line is now active
Frequently Asked Questions (FAQ)
1. Why do we use Docker agents? It ensures that tests run in an isolated and clean environment.
2. What should I do if the webhook does not occur? You can add a manual webhook from the GitHub repo settings.
3. Is it necessary to use Jenkinsfile? No, but “Pipeline as Code” is the industry standard.
Result
You have established a modern GitHub-integrated, Docker-based Jenkins CI pipeline on Ubuntu 20.04. Now every commit is automatically tested and errors are caught early.
You can safely scale your CI/CD processes by running this structure on the GenixNode infrastructure

