jenkins update

This commit is contained in:
Marcus Almert
2025-10-29 15:34:00 +01:00
parent 21a1f1043c
commit 2c0744c033

16
Jenkinsfile vendored
View File

@@ -37,32 +37,25 @@ pipeline {
stage('Deploy to VM') {
steps {
// Use Jenkins credentials (username + password)
withCredentials([usernamePassword(credentialsId: 'deploy-pass-id', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
// Install sshpass if not available
sh '''
# Install sshpass if missing
if ! command -v sshpass >/dev/null 2>&1; then
echo "Installing sshpass..."
sudo apt-get update -y && sudo apt-get install -y sshpass
fi
'''
// Upload frontend build
sh '''
echo "Uploading frontend build ..."
sshpass -p "$PASS" rsync -avz --delete \
-e "ssh -o StrictHostKeyChecking=no" \
frontend/dist/ $USER@$DEPLOY_HOST:$APP_DIR/frontend/dist/
'''
// Upload backend code
sh '''
echo "Uploading backend ..."
sshpass -p "$PASS" rsync -avz --delete \
-e "ssh -o StrictHostKeyChecking=no" \
backend/ $USER@$DEPLOY_HOST:$APP_DIR/backend/
'''
// Restart backend service
sh '''
echo "Restarting backend service ..."
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no \
$USER@$DEPLOY_HOST "
cd $APP_DIR/backend &&
@@ -73,6 +66,7 @@ pipeline {
}
}
}
}
post {