Complete step-by-step guide to set up Jenkins with DevSecOps pipeline
- Docker Desktop installed and running
- Git configured with your credentials
- GitHub Personal Access Token ready
- DockerHub account credentials ready
# Navigate to your project directory
cd "C:\Users\91967\OneDrive\Documents\GitHub\devops-sample-app"
# Start Jenkins with all security tools
docker-compose up -d
# Wait for Jenkins to start (this will take 3-5 minutes for first run)
Write-Host "⏳ Waiting for Jenkins to start..." -ForegroundColor Yellow
Start-Sleep 180
# Check if Jenkins is running
docker ps# Get the initial admin password
$adminPassword = docker exec jenkins-devsecops cat /var/jenkins_home/secrets/initialAdminPassword
Write-Host "🔑 Jenkins Admin Password: $adminPassword" -ForegroundColor Green
# Copy to clipboard (optional)
$adminPassword | Set-Clipboard
Write-Host "📋 Password copied to clipboard!" -ForegroundColor Blue# Check if all security tools are installed in Jenkins
docker exec jenkins-devsecops bash -c "
echo '🔍 Verifying security tools installation:'
echo '✅ Gitleaks:' && gitleaks version
echo '✅ Trivy:' && trivy version | head -1
echo '✅ Hadolint:' && hadolint --version
echo '✅ Semgrep:' && semgrep --version
echo '✅ Checkov:' && checkov --version
echo '✅ detect-secrets:' && detect-secrets --version
echo '✅ Bandit:' && bandit --version
echo '✅ Safety:' && safety --version
echo '🎉 All security tools are ready!'
"Expected Output: All tools should show their version numbers.
- Open browser: Navigate to
http://localhost:8080 - Enter admin password: Use the password from Step 1.2
- Install suggested plugins: Click "Install suggested plugins"
- Wait for installation: This takes 2-3 minutes
-
Fill out the form:
- Username:
admin - Password:
admin123(or your preferred password) - Full name:
DevSecOps Admin - Email:
admin@devsecops.local
- Username:
-
Click "Save and Continue"
-
Jenkins URL: Keep default
http://localhost:8080/ -
Click "Save and Finish" → "Start using Jenkins"
-
Go to: Manage Jenkins → Plugins → Available plugins
-
Search and install these plugins:
- ✅ HTML Publisher Plugin (for security reports)
- ✅ Warnings Next Generation Plugin (for security scan results)
- ✅ Pipeline Stage View Plugin (for pipeline visualization)
- ✅ Blue Ocean (modern UI - optional)
- ✅ JUnit Plugin (for test results)
-
Click "Install without restart"
-
Wait for installation (2-3 minutes)
-
Navigate to: Manage Jenkins → Credentials → System → Global credentials (unrestricted)
-
Click "Add Credentials"
-
Configure GitHub PAT:
- Kind: Username with password
- Scope: Global
- Username:
eknathdj(your GitHub username) - Password:
your-github-personal-access-token - ID:
github-creds - Description:
GitHub Personal Access Token for DevSecOps
-
Click "Create"
-
Click "Add Credentials" again
-
Configure DockerHub:
- Kind: Username with password
- Scope: Global
- Username:
your-dockerhub-username - Password:
your-dockerhub-password - ID:
dockerhub-creds - Description:
DockerHub Registry Credentials
-
Click "Create"
-
Click "New Item"
-
Configure:
- Name:
devsecops-sample-app - Type: Pipeline
- Click "OK"
- Name:
-
General Tab:
- Description:
DevSecOps CI/CD Pipeline with Security Scanning - ✅ GitHub project:
https://github.com/eknathdj/devops-sample-app
- Description:
-
Build Triggers:
- ✅ GitHub hook trigger for GITScm polling
- ✅ Poll SCM:
H/5 * * * *(every 5 minutes)
-
Pipeline Configuration:
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL:
https://github.com/eknathdj/devops-sample-app - Credentials: Select
github-creds - Branch Specifier:
*/main - Script Path:
Jenkinsfile.devsecops
-
Additional Behaviours (click "Add"):
- ✅ Wipe out repository & force clone
- ✅ Check out to specific local branch:
main
-
Click "Save"
-
Go back to pipeline configuration
-
Check "This project is parameterized"
-
Add String Parameters:
Parameter 1:
- Name:
DOCKER_IMAGE - Default Value:
eknathdj/devops-sample-app - Description:
Docker image name
Parameter 2:
- Name:
SECURITY_GATE_CRITICAL - Default Value:
0 - Description:
Maximum critical vulnerabilities allowed
Parameter 3:
- Name:
SECURITY_GATE_HIGH - Default Value:
5 - Description:
Maximum high vulnerabilities allowed
Parameter 4:
- Name:
SECURITY_GATE_MEDIUM - Default Value:
10 - Description:
Maximum medium vulnerabilities allowed
- Name:
-
Click "Save"
-
Go to your pipeline:
devsecops-sample-app -
Click "Build with Parameters"
-
Keep default parameters and click "Build"
-
Monitor the build:
- Click on the build number (e.g.,
#1) - Click "Console Output"
- Watch the security scans execute
- Click on the build number (e.g.,
You should see these stages executing:
🔧 Setup & Checkout (1-2 minutes)
├── Clean workspace
├── Configure Git
└── Checkout code
🔍 Pre-Build Security Scans (5-8 minutes)
├── 🔐 Secret Detection (Gitleaks + detect-secrets)
├── 📋 SAST Analysis (Semgrep)
└── 🛡️ Infrastructure Security (Checkov + kube-score)
🔨 Build & Test (2-3 minutes)
├── Build Docker image
└── Run application tests
🔍 Container Security Scans (8-12 minutes)
├── 🛡️ Trivy Vulnerability Scan
└── 🔍 Trivy Configuration Scan
📊 Security Report Generation (1-2 minutes)
├── Generate HTML reports
├── Archive security artifacts
└── Publish security dashboard
🚀 Deploy (2-3 minutes) [Only on main branch]
├── Push to DockerHub
├── Update Kubernetes manifests
└── Commit changes back to Git
After the build completes:
-
Go to build page (e.g., Build #1)
-
Check "Build Artifacts":
security-scan-results.tar.gz- All security reportspipeline-success.txtorpipeline-failure.txt- Build summary
-
View Security Dashboard:
- Look for "DevSecOps Security Report" link
- Review security metrics and findings
-
Check Console Output for security gate results:
✅ Secret Detection: No secrets detected ✅ SAST Analysis: 0 critical, 2 high issues ✅ Container Security: 0 critical, 3 high vulnerabilities ✅ All security gates passed!
-
Go to your GitHub repository:
https://github.com/eknathdj/devops-sample-app -
Settings → Webhooks → Add webhook
-
Configure webhook:
- Payload URL:
http://YOUR_IP:8080/github-webhook/ - Content type:
application/json - Which events: Just the push event
- ✅ Active
- Payload URL:
-
Click "Add webhook"
If you're running locally, use ngrok for public access:
# Install ngrok (if not installed)
choco install ngrok
# Expose Jenkins to internet
ngrok http 8080
# Use the ngrok URL in webhook
# Example: https://abc123.ngrok.io/github-webhook/-
Make a small change to README.md:
# Add a line to README.md echo "`n<!-- DevSecOps Pipeline Test -->" >> README.md # Commit and push git add README.md git commit -m "Test DevSecOps pipeline automation" git push origin main
-
Check Jenkins: A new build should start automatically
-
Monitor the build through all security stages
-
Check that all security tools run:
- Gitleaks secret detection
- Semgrep SAST analysis
- Trivy vulnerability scanning
- Checkov IaC security
- Hadolint Dockerfile linting
-
Verify security gates work:
- Build should pass if within thresholds
- Build should fail if security issues exceed limits
-
Check security reports are generated:
- HTML security dashboard
- JSON reports for each tool
- Consolidated security summary
- Jenkins with 8 Security Tools running in Docker
- Automated DevSecOps Pipeline with security gates
- GitHub Integration with webhooks
- DockerHub Integration for secure image publishing
- Comprehensive Security Reporting with dashboards
- Security Gate Enforcement with configurable thresholds
- Secret Detection: Gitleaks + detect-secrets
- SAST Analysis: Semgrep + Bandit
- Container Security: Trivy vulnerability + configuration scanning
- IaC Security: Checkov + kube-score
- Dependency Scanning: Safety + npm audit
- Dockerfile Security: Hadolint linting
- Fine-tune security thresholds based on your risk tolerance
- Set up ArgoCD for GitOps deployment
- Configure monitoring and alerting for security events
- Train your team on the DevSecOps workflow
Jenkins won't start:
# Check Docker logs
docker logs jenkins-devsecops
# Restart if needed
docker-compose restartSecurity tools not found:
# Rebuild container with tools
docker-compose down
docker-compose up --build -dBuild fails at security stage:
# Check security tool logs in Jenkins console output
# Adjust security thresholds if needed
# Review security reports for specific issuesGitHub webhook not working:
- Check webhook URL is correct
- Verify Jenkins is accessible from internet (use ngrok for local)
- Check webhook delivery in GitHub settings
🎯 Congratulations! You now have a production-ready DevSecOps pipeline!