CI/CD pipeline menggunakan Jenkins dan Docker untuk build, test, dan deliver aplikasi Python dengan PyInstaller.
simple-python-pyinstaller-app/
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile.jenkins # Custom Jenkins image dengan Docker CLI
├── .env # Auto-generated (host Docker GID)
├── Jenkinsfile # Pipeline definition
├── nginx/
│ └── default.conf # NGINX reverse proxy
└── sources/
├── add2vals.py # Main application
├── calc.py # Calc library
└── test_calc.py # Unit tests
- Docker & Docker Compose
- Git
# Generate .env dengan Docker GID dari host
echo "DOCKER_GID=$(getent group docker | cut -d: -f3)" > .envdocker compose build --no-cache
docker compose up -d# Dapatkan admin password
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPasswordAkses Jenkins:
- Via NGINX: http://localhost:9000
- Direct: http://localhost:49000
- Install suggested plugins
- Buat admin user
- Buat akun
dicoding(Setup → Security → Allow users to sign up)
- Login sebagai
dicoding - New Item → Pipeline → Pipeline script from SCM
- SCM: Git, repo URL Anda, branch
*/master - Script Path:
Jenkinsfile - Build Triggers: Poll SCM →
H/2 * * * * - Install plugin Blue Ocean (opsional)
- Build — Build aplikasi dengan PyInstaller di dalam container
python:3.9-slim - Test — Jalankan pytest pada
sources/test_calc.py - Deliver — Archive artifacts (log.txt dan dist/*)