jenkins update
This commit is contained in:
42
Jenkinsfile
vendored
42
Jenkinsfile
vendored
@@ -37,42 +37,36 @@ 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 '''
|
||||
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
|
||||
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/
|
||||
'''
|
||||
-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/
|
||||
'''
|
||||
-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 &&
|
||||
source venv/bin/activate &&
|
||||
sudo systemctl restart mitm-webserver-backend.service
|
||||
"
|
||||
'''
|
||||
$USER@$DEPLOY_HOST "
|
||||
cd $APP_DIR/backend &&
|
||||
source venv/bin/activate &&
|
||||
sudo systemctl restart mitm-webserver-backend.service
|
||||
"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
post {
|
||||
|
||||
Reference in New Issue
Block a user