-
Install Jenkins:
# Windows (using chocolatey) choco install jenkins # macOS brew install jenkins-lts
-
Install Docker:
# Windows (using winget) winget install Docker.DockerDesktop # macOS brew install --cask docker
-
Install SonarQube:
# Using Docker docker run -d --name sonarqube -p 9000:9000 sonarqube:latest
-
Start Jenkins:
# Windows net start jenkins # macOS brew services start jenkins-lts
-
Access Jenkins:
- URL: http://localhost:8080
- Get initial admin password:
# Windows type C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword # macOS sudo cat /var/lib/jenkins/secrets/initialAdminPassword
-
Install required plugins:
- Docker Pipeline
- SonarQube Scanner
- GitLab/GitHub Integration
- Blue Ocean
-
Configure credentials:
- Jenkins → Credentials → System → Global credentials
- Add Docker registry credentials
- Add GitLab/GitHub credentials
- Add SonarQube token
-
Configure SonarQube:
- Manage Jenkins → Configure System
- Find "SonarQube servers"
- Add SonarQube URL and authentication token
-
Configure Docker:
- Ensure Jenkins user has Docker permissions
- Test Docker connectivity:
sudo usermod -aG docker jenkins systemctl restart jenkins
-
Create new pipeline:
- New Item → Pipeline
- Configure Git repository
- Use provided Jenkinsfile
-
Pipeline stages:
stage('Build') { // Builds Docker image } stage('Test') { // Runs tests in container } stage('Security Scan') { // SonarQube analysis } stage('Deploy') { // Deploys to environment }
-
Environment variables:
DOCKER_IMAGE=myapp DOCKER_TAG=${BUILD_NUMBER} SONAR_PROJECT_KEY=my-app
-
SonarQube setup:
- Access SonarQube: http://localhost:9000
- Default credentials: admin/admin
- Create new project
- Generate authentication token
-
Docker security:
# Enable Docker content trust export DOCKER_CONTENT_TRUST=1 # Scan images docker scan myapp:latest
-
Jenkins security:
- Enable CSRF protection
- Configure authentication
- Set up authorization strategy
-
Development:
./scripts/deploy.sh development
-
Staging:
./scripts/deploy.sh staging
-
Production:
./scripts/deploy.sh production
-
Jenkins monitoring:
- Pipeline trends
- Build statistics
- Test results
-
SonarQube monitoring:
- Code quality
- Security issues
- Technical debt
-
Pipeline issues:
- Check Jenkins logs
- Verify Jenkinsfile syntax
- Test Docker connectivity
-
Build failures:
- Check build logs
- Verify Docker build context
- Check resource constraints
-
Deployment issues:
- Verify environment variables
- Check deployment scripts
- Validate configurations
-
Jenkins backup:
# Backup Jenkins home tar -czf jenkins_backup.tar.gz /var/lib/jenkins
-
Docker cleanup:
# Remove unused images docker image prune -a # Remove unused volumes docker volume prune
- Fork the repository
- Create feature branch
- Make changes
- Submit pull request
For issues and support:
- Create GitHub issue
- Email: [email protected]