77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
pipeline {
|
|
agent {
|
|
docker {
|
|
image 'python:3'
|
|
}
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout Code') {
|
|
steps {
|
|
git url: 'http://linepe.de:5050/volume1/git/workspacewanderers.git',
|
|
branch: 'main',
|
|
credentialsId: 'cred_nas_git'
|
|
}
|
|
}
|
|
|
|
stage('Set Up Dependencies') {
|
|
steps {
|
|
sh '''
|
|
apt-get update && apt-get install -y python3 python3-pip
|
|
pip install --upgrade pip
|
|
pip install flask pytest
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
sh '''
|
|
docker build -t service1:latest .
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Run Tests') {
|
|
steps {
|
|
sh '''
|
|
pytest --cov tests/
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Push to Local Registry') {
|
|
steps {
|
|
sh '''
|
|
docker login --username your-registry-username \
|
|
--password your-registry-password http://localhost:5000
|
|
docker tag service1:latest localhost:5000/service1:latest
|
|
docker push localhost:5000/service1:latest
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Deploy Service') {
|
|
steps {
|
|
sh '''
|
|
# Replace with your deployment strategy (e.g., Docker Compose)
|
|
docker run -d --name service1 localhost:5000/service1:latest
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
mail to: 'notification@example.com',
|
|
subject: 'Jenkins Build Successful for Service 1',
|
|
body: 'The build and deployment of Service 1 were successful.'
|
|
}
|
|
|
|
failure {
|
|
mail to: 'notification@example.com',
|
|
subject: 'Jenkins Build Failed for Service 1',
|
|
body: 'The build or deployment of Service 1 failed. Please investigate.'
|
|
}
|
|
}
|
|
} |