jenkins update
This commit is contained in:
42
Jenkinsfile
vendored
42
Jenkinsfile
vendored
@@ -37,42 +37,36 @@ pipeline {
|
|||||||
|
|
||||||
stage('Deploy to VM') {
|
stage('Deploy to VM') {
|
||||||
steps {
|
steps {
|
||||||
// Use Jenkins credentials (username + password)
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'deploy-pass-id', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
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
|
if ! command -v sshpass >/dev/null 2>&1; then
|
||||||
echo "Installing sshpass..."
|
echo "Installing sshpass..."
|
||||||
sudo apt-get update -y && sudo apt-get install -y sshpass
|
sudo apt-get update -y && sudo apt-get install -y sshpass
|
||||||
fi
|
fi
|
||||||
'''
|
|
||||||
|
|
||||||
// Upload frontend build
|
echo "Uploading frontend build ..."
|
||||||
sh '''
|
|
||||||
sshpass -p "$PASS" rsync -avz --delete \
|
sshpass -p "$PASS" rsync -avz --delete \
|
||||||
-e "ssh -o StrictHostKeyChecking=no" \
|
-e "ssh -o StrictHostKeyChecking=no" \
|
||||||
frontend/dist/ $USER@$DEPLOY_HOST:$APP_DIR/frontend/dist/
|
frontend/dist/ $USER@$DEPLOY_HOST:$APP_DIR/frontend/dist/
|
||||||
'''
|
|
||||||
|
|
||||||
// Upload backend code
|
echo "Uploading backend ..."
|
||||||
sh '''
|
|
||||||
sshpass -p "$PASS" rsync -avz --delete \
|
sshpass -p "$PASS" rsync -avz --delete \
|
||||||
-e "ssh -o StrictHostKeyChecking=no" \
|
-e "ssh -o StrictHostKeyChecking=no" \
|
||||||
backend/ $USER@$DEPLOY_HOST:$APP_DIR/backend/
|
backend/ $USER@$DEPLOY_HOST:$APP_DIR/backend/
|
||||||
'''
|
|
||||||
|
|
||||||
// Restart backend service
|
echo "Restarting backend service ..."
|
||||||
sh '''
|
|
||||||
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no \
|
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no \
|
||||||
$USER@$DEPLOY_HOST "
|
$USER@$DEPLOY_HOST "
|
||||||
cd $APP_DIR/backend &&
|
cd $APP_DIR/backend &&
|
||||||
source venv/bin/activate &&
|
source venv/bin/activate &&
|
||||||
sudo systemctl restart mitm-webserver-backend.service
|
sudo systemctl restart mitm-webserver-backend.service
|
||||||
"
|
"
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|||||||
Reference in New Issue
Block a user