1. Jenkins Configuration Overview
Jenkins is commonly used as a CI/CD server to check out source code, build applications, run tests, publish artifacts or container images, and deploy applications.
| Component | Purpose |
|---|---|
| Jenkins | CI/CD orchestration |
| Java | Runtime required by Jenkins |
| Git | Source-code checkout |
| Maven | Build Spring Boot/Java applications |
| Docker | Container build/run when required |
| SSH | Remote Linux deployment |
| Nginx | Optional reverse proxy and HTTPS endpoint |
2. Jenkins Installation — Windows
Step 1 — Install Java
Install a JDK supported by your Jenkins release, then verify:
java -version
where java
Step 2 — Configure JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk-17
Add %JAVA_HOME%\bin to PATH and verify:
echo %JAVA_HOME%
java -version
Step 3 — Install Jenkins
Install Jenkins using the official Windows installer. During installation, Jenkins can be configured as a Windows service.
Step 4 — Check Jenkins service
services.msc
Find the Jenkins service.
Step 5 — Start, stop and restart Jenkins
net start jenkins
net stop jenkins
net stop jenkins
net start jenkins
Step 6 — Check port 8080
netstat -ano | findstr :8080
curl http://localhost:8080
Step 7 — Initial administrator password
A common Windows Jenkins home location is:
C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword
Confirm the actual JENKINS_HOME for your installation before relying on this path.
Step 8 — Open Jenkins
http://localhost:8080
3. Jenkins Installation — Linux
Step 1 — Check Linux version
cat /etc/os-release
Step 2 — Update packages
Ubuntu/Debian:
sudo apt update
sudo apt upgrade -y
RHEL/Rocky/AlmaLinux:
sudo dnf update -y
Step 3 — Install supported Java
Example for Ubuntu:
sudo apt install -y openjdk-17-jdk
java -version
Step 4 — Find JAVA_HOME
readlink -f $(which java)
Example JDK directory:
/usr/lib/jvm/java-17-openjdk-amd64
For a persistent setting:
sudo nano /etc/environment
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
Reload:
source /etc/environment
echo $JAVA_HOME
java -version
Step 5 — Install Jenkins
Configure the official Jenkins repository for your Linux distribution, then install Jenkins. On Debian/Ubuntu systems:
sudo apt update
sudo apt install -y jenkins
Step 6 — Enable and start
sudo systemctl enable jenkins
sudo systemctl start jenkins
Step 7 — Check status and logs
sudo systemctl status jenkins
sudo journalctl -u jenkins -f
Step 8 — Check port
sudo ss -lntp | grep 8080
curl http://localhost:8080
Step 9 — Initial password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
/var/lib/jenkins.4. Jenkins Initial Configuration
http://localhost:8080 or http://SERVER-IP:8080.https://jenkins.example.com/.Linux:
echo $JENKINS_HOME
sudo systemctl cat jenkins
Windows:
echo %JENKINS_HOME%
5. Configure JDK, Git and Maven
5.1 JDK
Use Manage Jenkins → Tools → JDK installations and configure the JDK required by your jobs.
5.2 Git
Windows:
git --version
where git
Linux:
git --version
which git
Configure Git under Manage Jenkins → Tools → Git installations if required.
5.3 Maven
mvn -version
Windows:
where mvn
Linux:
which mvn
Configure Maven under Manage Jenkins → Tools → Maven installations.
./mvnw on Linux and mvnw.cmd on Windows) for reproducible project builds.6. Configure Git Repository Access
Option A — SSH
ssh-keygen -t ed25519 -C "jenkins-ci"
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
Add the public key to your Git provider as an appropriate deploy key/service credential.
Option B — HTTPS + Token
Create a Jenkins credential using a Personal Access Token or equivalent token. Do not store a normal account password in the Jenkinsfile.
Navigate to:
Manage Jenkins → Credentials → System → Global credentials
Pipeline checkout example
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
credentialsId: 'git-credentials',
url: 'git@github.com:organization/project.git'
}
}
}
}
7. Jenkins Credentials
| Credential Type | Typical Use |
|---|---|
| Username + Password | Legacy systems and selected registries |
| SSH Username with Private Key | Git SSH and Linux deployment |
| Secret Text | API tokens and application secrets |
| Secret File | Configuration files/certificates |
Example credential IDs
git-credentials
docker-registry
linux-deploy-key
nexus-credentials
sonarqube-token
8. Create Jenkins Pipeline
8.1 Create Pipeline job
- Select New Item.
- Enter a job name.
- Select Pipeline.
- Click OK.
- Configure the Pipeline definition.
8.2 Linux Spring Boot Maven pipeline
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
credentialsId: 'git-credentials',
url: 'git@github.com:organization/frt-test-series.git'
}
}
stage('Build') {
steps {
sh './mvnw clean package -DskipTests'
}
}
stage('Test') {
steps {
sh './mvnw test'
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'target/*.jar',
fingerprint: true
}
}
}
}
8.3 Windows pipeline
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
credentialsId: 'git-credentials',
url: 'https://github.com/organization/project.git'
}
}
stage('Build') {
steps {
bat 'mvnw.cmd clean package -DskipTests'
}
}
stage('Test') {
steps {
bat 'mvnw.cmd test'
}
}
stage('Archive') {
steps {
archiveArtifacts artifacts: 'target\\*.jar',
fingerprint: true
}
}
}
}
9. Git Webhook Configuration
Step 1 — Jenkins job
Configure the appropriate SCM webhook trigger, such as the GitHub hook trigger provided by the installed GitHub integration.
Step 2 — Git provider
Configure a webhook in the repository settings using the Jenkins endpoint appropriate to your integration. A common GitHub endpoint is:
https://jenkins.example.com/github-webhook/
Step 3 — Test
- Push a commit.
- Check webhook delivery status.
- Check Jenkins build history.
- Open Console Output.
10. Linux Deployment Using Jenkins + SSH
Step 1 — Create deployment user
sudo useradd -m -s /bin/bash deployuser
Step 2 — Generate deployment key on Jenkins agent
ssh-keygen -t ed25519 -C "jenkins-deploy"
Step 3 — Copy public key to target server
ssh-copy-id deployuser@SERVER_IP
Step 4 — Test
ssh deployuser@SERVER_IP
Step 5 — Add private key to Jenkins
Go to:
Manage Jenkins → Credentials → System → Global credentials
Select SSH Username with private key.
Step 6 — Deployment pipeline example
pipeline {
agent any
stages {
stage('Build') {
steps {
sh './mvnw clean package -DskipTests'
}
}
stage('Deploy') {
steps {
sshagent(credentials: ['linux-deploy-key']) {
sh '''
scp target/*.jar deployuser@SERVER_IP:/opt/apps/myapp/
ssh deployuser@SERVER_IP 'sudo systemctl restart myapp'
'''
}
}
}
}
}
11. Deploy Spring Boot Application as systemd Service
Create service
sudo nano /etc/systemd/system/myapp.service
[Unit]
Description=My Spring Boot Application
After=network.target
[Service]
User=deployuser
WorkingDirectory=/opt/apps/myapp
ExecStart=/usr/bin/java -jar /opt/apps/myapp/myapp.jar
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable and start
sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp
Restart after Jenkins deployment
sudo systemctl daemon-reload
sudo systemctl restart myapp
sudo systemctl status myapp --no-pager
Application logs
sudo journalctl -u myapp -f
12. Jenkins + Docker
Verify Docker
Linux:
docker --version
sudo systemctl status docker
Windows:
docker --version
Linux Jenkins access to Docker
sudo usermod -aG docker jenkins
sudo systemctl restart jenkins
Build and tag image
docker build -t frt-test-series:${BUILD_NUMBER} .
docker tag frt-test-series:${BUILD_NUMBER} REGISTRY_HOST/frt-test-series:${BUILD_NUMBER}
Push image
docker login REGISTRY_HOST
docker push REGISTRY_HOST/frt-test-series:${BUILD_NUMBER}
13. Jenkins Behind Nginx on Linux
Example Nginx configuration
server {
listen 80;
server_name jenkins.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Validate and reload
sudo nginx -t
sudo systemctl reload nginx
Configure public Jenkins URL
https://jenkins.example.com/
14. Jenkins Service Management
Linux
sudo systemctl status jenkins
sudo systemctl start jenkins
sudo systemctl stop jenkins
sudo systemctl restart jenkins
sudo systemctl enable jenkins
sudo journalctl -u jenkins -f
Windows
net start jenkins
net stop jenkins
sc query jenkins
services.msc
Port diagnostics
Linux:
sudo ss -lntp | grep 8080
Windows:
netstat -ano | findstr :8080
15. Jenkins Security Configuration
| Area | Recommendation |
|---|---|
| Authentication | Use strong administrator accounts and enterprise identity integration where available. |
| Authorization | Use role-based or matrix-based permissions appropriate to your team. |
| CSRF | Keep Jenkins security protections enabled. |
| Credentials | Use Jenkins Credentials or an external secrets manager. |
| Plugins | Update plugins and remove unused plugins. |
| Network | Restrict access with firewall, security groups or VPN where appropriate. |
| Agents | Use dedicated agents for specialized or high-risk builds. |
| Backups | Back up Jenkins configuration and job definitions. |
16. Troubleshooting
Jenkins does not start — Linux
sudo systemctl status jenkins
sudo journalctl -u jenkins -n 200 --no-pager
java -version
Port 8080 already in use
Linux:
sudo lsof -i :8080
sudo ss -lntp | grep :8080
Windows:
netstat -ano | findstr :8080
tasklist /FI "PID eq PID_NUMBER"
Git clone fails
git --version
ssh -T git@github.com
- Verify repository URL.
- Verify credential ID.
- Verify branch.
- Verify deploy key/PAT permissions.
- Verify firewall and network access.
Maven not found
mvn -version
Linux:
which mvn
Windows:
where mvn
Use Maven Wrapper when practical:
Linux:
./mvnw clean package
Windows:
mvnw.cmd clean package
Docker permission failure
sudo systemctl status docker
sudo -u jenkins docker ps
groups jenkins
Webhook does not trigger build
- Verify Jenkins public URL.
- Verify webhook URL.
- Verify DNS and HTTPS.
- Verify firewall/security group.
- Check webhook delivery logs.
- Check Jenkins job trigger configuration.
17. Jenkins Backup
Linux example
sudo systemctl stop jenkins
sudo tar -czf jenkins-home-backup.tar.gz /var/lib/jenkins
sudo systemctl start jenkins
Windows PowerShell example
Compress-Archive `
-Path "C:\ProgramData\Jenkins\.jenkins\*" `
-DestinationPath "D:\Backup\jenkins-home-backup.zip"
18. Complete Jenkins Configuration Checklist
Windows
- ☐ Install supported JDK
- ☐ Configure JAVA_HOME
- ☐ Install Jenkins
- ☐ Verify Jenkins service
- ☐ Retrieve initial password
- ☐ Open Jenkins
- ☐ Install required plugins
- ☐ Create administrator
- ☐ Configure Jenkins URL
- ☐ Install Git
- ☐ Configure Maven/Maven Wrapper
- ☐ Configure credentials
- ☐ Create pipeline
- ☐ Test build
- ☐ Configure webhook if required
Linux
- ☐ Update OS
- ☐ Install supported JDK
- ☐ Configure JAVA_HOME
- ☐ Install Jenkins
- ☐ Enable/start Jenkins
- ☐ Verify systemd status
- ☐ Check logs
- ☐ Configure firewall
- ☐ Install Git
- ☐ Configure Maven/Maven Wrapper
- ☐ Configure credentials
- ☐ Configure SSH deployment
- ☐ Configure Docker if required
- ☐ Create pipeline
- ☐ Configure webhook
- ☐ Configure Nginx/HTTPS
- ☐ Configure backups
19. Recommended CI/CD Flow for a Spring Boot Microservices Project
Developer
|
| git push
v
GitHub / GitLab
|
| Webhook
v
Jenkins
|
+-- Checkout source
|
+-- Validate Java / Maven
|
+-- mvn clean
|
+-- mvn test
|
+-- mvn package
|
+-- Static analysis (optional)
|
+-- Build Docker image (optional)
|
+-- Push image / Nexus / Artifactory
|
+-- Deploy to DEV
|
+-- Health check
|
+-- QA approval
|
+-- Deploy to QA
|
+-- Production approval
|
+-- Deploy to Production
|
+-- Health verification
20. Quick Command Reference
Linux
# Java
java -version
# Jenkins
sudo systemctl status jenkins
sudo systemctl restart jenkins
sudo journalctl -u jenkins -f
# Port
sudo ss -lntp | grep 8080
# Git
git --version
# Maven
mvn -version
# Docker
docker --version
sudo systemctl status docker
# Initial password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Windows
REM Java
java -version
REM Jenkins service
net start jenkins
net stop jenkins
sc query jenkins
REM Port
netstat -ano | findstr :8080
REM Git
git --version
REM Maven
mvn -version
REM Docker
docker --version
21. Final Recommended Setup
| Layer | Recommended Configuration |
|---|---|
| Source Control | GitHub/GitLab/Bitbucket |
| CI Server | Jenkins on Linux for production |
| Runtime | Jenkins-supported JDK |
| Build | Maven Wrapper / Maven |
| Credentials | Jenkins Credentials / external secret manager |
| Artifact | Nexus / Artifactory |
| Container | Docker where required |
| Deployment | systemd/SSH, Docker, Kubernetes or Helm |
| Reverse Proxy | Nginx + HTTPS |
| Monitoring | Jenkins and application monitoring/logging |
| Backup | JENKINS_HOME + tested backup strategy |