fix: use psutil for reliable CPU and memory metrics
This commit is contained in:
26
platform/Jenkinsfile
vendored
26
platform/Jenkinsfile
vendored
@@ -1,8 +1,12 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
DOCKER_BUILDKIT = '1'
|
||||
BUILDKIT_PROGRESS = 'plain'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
echo '✅ Code checked out from Gitea'
|
||||
@@ -12,8 +16,16 @@ pipeline {
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
sh '''
|
||||
docker build -t management-platform:latest ./platform/
|
||||
docker pull management-platform:latest 2>/dev/null || true
|
||||
|
||||
docker build \
|
||||
--cache-from management-platform:latest \
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||
-t management-platform:latest \
|
||||
./platform/
|
||||
|
||||
echo "✅ Docker image built"
|
||||
docker images management-platform:latest --format "Size: {{.Size}}"
|
||||
'''
|
||||
}
|
||||
}
|
||||
@@ -23,6 +35,7 @@ pipeline {
|
||||
sh '''
|
||||
docker stop management-platform 2>/dev/null || true
|
||||
docker rm management-platform 2>/dev/null || true
|
||||
|
||||
docker run -d \
|
||||
--name management-platform \
|
||||
--restart unless-stopped \
|
||||
@@ -33,10 +46,6 @@ pipeline {
|
||||
-v /etc/shadow:/etc/shadow:ro \
|
||||
-v /root/management-platform/config.py:/app/config.py:ro \
|
||||
-v /root/management-platform/modules:/app/modules:ro \
|
||||
-v /proc/meminfo:/proc/meminfo:ro \
|
||||
-v /proc/stat:/proc/stat:ro \
|
||||
-v /proc/loadavg:/proc/loadavg:ro \
|
||||
-v /proc/uptime:/proc/uptime:ro \
|
||||
management-platform:latest
|
||||
|
||||
sleep 5
|
||||
@@ -56,7 +65,7 @@ pipeline {
|
||||
steps {
|
||||
sh '''
|
||||
sleep 3
|
||||
if curl -f http://localhost:8088/health 2>/dev/null || curl -f http://173.249.20.244:8088/ 2>/dev/null; then
|
||||
if curl -f http://localhost:8088/ 2>/dev/null; then
|
||||
echo "✅ Platform responding"
|
||||
else
|
||||
echo "⚠️ Health check failed"
|
||||
@@ -70,11 +79,10 @@ pipeline {
|
||||
post {
|
||||
success {
|
||||
echo '✅ Pipeline succeeded — platform deployed'
|
||||
// Optionnel: notification
|
||||
sh 'docker image prune -f --filter "until=24h" 2>/dev/null || true'
|
||||
}
|
||||
failure {
|
||||
echo '❌ Pipeline failed — check logs'
|
||||
// Afficher les logs Docker en cas d'échec
|
||||
sh 'docker logs management-platform --tail=30 2>/dev/null || true'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user