python-appv2/Jenkinsfile

70 lines
1.2 KiB
Text
Raw Normal View History

2025-12-15 17:16:00 +00:00
pipeline {
2025-12-15 17:44:59 +00:00
agent {
docker {
image 'python:3.11-slim'
}
}
environment {
APP_PORT = '3001'
}
2025-12-15 17:16:00 +00:00
stages {
2025-12-15 17:44:59 +00:00
stage('Install Dependencies') {
2025-12-15 17:16:00 +00:00
steps {
2025-12-15 17:44:59 +00:00
sh '''
python --version
pip install --upgrade pip
pip install -r requirements.txt
'''
2025-12-15 17:16:00 +00:00
}
}
2025-12-15 17:44:59 +00:00
stage('Unit Tests') {
2025-12-15 17:16:00 +00:00
steps {
sh 'pytest test_app.py'
}
}
2025-12-15 17:44:59 +00:00
stage('Run & Integration Test') {
parallel {
stage('Start App') {
steps {
sh '''
gunicorn --bind 0.0.0.0:${APP_PORT} app:app &
echo $! > gunicorn.pid
'''
}
}
stage('Integration Test') {
steps {
sh '''
sleep 5
curl -f http://localhost:${APP_PORT}
'''
}
2025-12-15 17:39:15 +00:00
}
2025-12-15 17:16:00 +00:00
}
2025-12-15 17:44:59 +00:00
post {
always {
sh '''
if [ -f gunicorn.pid ]; then
kill $(cat gunicorn.pid) || true
fi
'''
2025-12-15 17:39:15 +00:00
}
2025-12-15 17:44:59 +00:00
}
}
stage('Containerization') {
steps {
echo 'Docker Build Image...'
echo 'Docker Tag Image...'
echo 'Docker Push Image...'
}
2025-12-15 17:16:00 +00:00
}
}
2025-12-15 17:44:59 +00:00
}