You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

51 lines
2.5 KiB

pipeline {
environment {
production_server_ip = "46.173.16.83"
production_server_name = "4e1f741c-3f7a-407d-904e-6778ec6e6219"
project_path = "/projects/dovodi/dovodi-backend"
gitBranch = "origin/master"
}
agent any
stages {
stage('🚀 Deploy Dovodi Backend (Background Build)') {
when { expression { gitBranch == "origin/master" } }
steps {
script {
withCredentials([usernamePassword(credentialsId: production_server_name, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh """
sshpass -p \$PASSWORD ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=120 \$USERNAME@${production_server_ip} << 'EOF'
cd ${project_path}
echo "⏳ Starting runner.sh in background to prevent timeout..."
rm -f /tmp/dovodi_backend_deploy_status.txt
rm -f /tmp/dovodi_backend_runner_deploy.log
nohup bash -c './runner.sh && echo "SUCCESS" > /tmp/dovodi_backend_deploy_status.txt || echo "FAIL" > /tmp/dovodi_backend_deploy_status.txt' > /tmp/dovodi_backend_runner_deploy.log 2>&1 &
echo "⏳ Process is running. Waiting for build and deploy to finish..."
while true; do
if [ -f /tmp/dovodi_backend_deploy_status.txt ]; then
STATUS=\$(cat /tmp/dovodi_backend_deploy_status.txt)
if [ "\$STATUS" = "SUCCESS" ]; then
echo "✅ Deployment completed successfully!"
break
else
echo "❌ ERROR: Deployment failed! Last 20 lines of log:"
tail -n 20 /tmp/dovodi_backend_runner_deploy.log
exit 1
fi
fi
sleep 10
done
EOF
"""
}
}
}
}
}
}