Update Jenkinsfile
This commit is contained in:
parent
547c27e564
commit
22f175dbfb
1 changed files with 55 additions and 26 deletions
81
Jenkinsfile
vendored
81
Jenkinsfile
vendored
|
|
@ -1,40 +1,69 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent docker { image 'python:alpine3.22' }
|
agent {
|
||||||
stages {
|
docker {
|
||||||
stage('Pre-build') {
|
image 'python:3.11-slim'
|
||||||
steps {
|
|
||||||
sh 'python3 -m venv venv'
|
|
||||||
sh 'source venv/bin/activate'
|
|
||||||
sh 'pip3 --version'
|
|
||||||
sh 'pip install -r requirements.txt'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Test') {
|
environment {
|
||||||
|
APP_PORT = '3001'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage('Install Dependencies') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
python --version
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Unit Tests') {
|
||||||
steps {
|
steps {
|
||||||
sh 'pytest test_app.py'
|
sh 'pytest test_app.py'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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}
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh '''
|
||||||
|
if [ -f gunicorn.pid ]; then
|
||||||
|
kill $(cat gunicorn.pid) || true
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Containerization') {
|
stage('Containerization') {
|
||||||
steps {
|
steps {
|
||||||
sh 'echo Docker Build Image..'
|
echo 'Docker Build Image...'
|
||||||
sh 'echo Docker Tag Image....'
|
echo 'Docker Tag Image...'
|
||||||
sh 'echo Docker Push Image......'
|
echo 'Docker Push Image...'
|
||||||
}
|
|
||||||
}
|
|
||||||
parallel {
|
|
||||||
stage('Run-and-test')
|
|
||||||
{
|
|
||||||
steps {
|
|
||||||
sh 'gunicorn --bind 0.0.0.0:3001 app:app'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Integration Testing') {
|
|
||||||
steps {
|
|
||||||
sh "sleep 10s"
|
|
||||||
sh 'curl localhost:3001'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue