Compare commits

..

9 Commits

Author SHA1 Message Date
56936d0300 This is a test from Vscode 2024-12-13 16:24:26 -05:00
cb6749f2e9 Updated Jenkinsfile 2024-11-17 17:16:10 -05:00
01cc3684eb Updated Jenkinsfile 2024-11-17 17:13:58 -05:00
6571799c9e Updated new Jenkinsfile 2024-11-17 15:36:10 -05:00
905b1d1ed5 Finally 2024-11-17 15:06:16 -05:00
88c44e6d62 Finally 2024-11-17 15:00:55 -05:00
5ff1a005a1 Finally 2024-11-17 14:59:53 -05:00
a948c5ce75 test Merge branch 'main' of http://192.168.1.31:4000/ngatia/workout_buddy into main 2024-11-17 14:42:20 -05:00
8e01d7daa0 Update README.md file 2024-11-17 14:41:59 -05:00
3 changed files with 7 additions and 122 deletions

127
Jenkinsfile vendored
View File

@@ -1,135 +1,20 @@
pipeline {
agent { label 'jenkins-master' }
tools {
// If you have Docker tool configured in Jenkins
docker 'Default'
}
// Environment variables
environment {
COMPOSE_PROJECT_NAME = "${env.JOB_NAME}-${env.BUILD_NUMBER}"
DOCKER_COMPOSE_FILE = 'docker-compose.yml'
}
agent { label 'jenkins-agent' }
stages {
stage('Cleanup') {
steps {
// Clean workspace before build
cleanWs()
// Stop any existing containers
sh 'docker-compose down --remove-orphans || true'
}
}
stage('Build') {
steps {
script {
try {
sh 'docker-compose build --no-cache'
} catch (err) {
error "Failed to build Docker images: ${err}"
}
}
sh 'docker-compose build'
}
}
stage('Test') {
/*stage('Test') {
steps {
script {
try {
// Run tests and capture the output
sh '''
docker-compose run --rm app python -m pytest \
--junitxml=test-results/junit.xml \
--cov=app \
--cov-report=xml:coverage-reports/coverage.xml
'''
} catch (err) {
error "Tests failed: ${err}"
}
}
sh 'docker-compose run --rm app python -m pytest'
}
post {
always {
// Publish test results even if tests fail
junit allowEmptyResults: true, testResults: 'test-results/*.xml'
// Publish coverage reports
publishCoverage adapters: [coberturaAdapter('coverage-reports/coverage.xml')]
}
}
}
stage('Security Scan') {
steps {
script {
try {
// Run security scanning on Docker images
sh 'docker scan app:latest || true'
} catch (err) {
// Don't fail the build but warn about security issues
warning "Security scan found issues: ${err}"
}
}
}
}
}*/
stage('Deploy') {
steps {
script {
try {
// Take backup of current deployment state
sh 'docker-compose ps > deployment-state.txt || true'
// Deploy with health check
sh '''
docker-compose up -d
# Wait for containers to be healthy
./scripts/wait-for-healthy.sh 300
'''
} catch (err) {
// If deployment fails, attempt rollback
error "Deployment failed: ${err}"
}
}
sh 'docker-compose up -d'
}
}
}
post {
always {
script {
// Cleanup resources regardless of build result
sh '''
# Save logs before cleanup
mkdir -p logs
docker-compose logs > logs/docker-compose.log || true
# Cleanup
docker-compose down --remove-orphans || true
docker system prune -f || true
'''
// Archive logs and deployment state
archiveArtifacts artifacts: 'logs/*, deployment-state.txt', allowEmptyArchive: true
}
}
success {
echo 'Pipeline completed successfully!'
// Add notifications for success (email, Slack, etc.)
}
failure {
echo 'Pipeline failed!'
// Add notifications for failure (email, Slack, etc.)
}
}
options {
// Set timeout for entire pipeline
timeout(time: 1, unit: 'HOURS')
// Keep build logs and artifacts for 10 builds
buildDiscarder(logRotator(numToKeepStr: '10'))
// Don't run concurrent builds
disableConcurrentBuilds()
}
}

View File

@@ -1,4 +1,3 @@
# workout_buddy
This is a test file for Workout buddy.
This is a dummy file also

View File

@@ -37,5 +37,6 @@ services:
depends_on:
- backend
#
#
volumes:
db-data: