pipeline { agent any environment { BOT_DIR = '/srv/fymious-tg-bot' VPS_HOST = '96.126.129.131' } stages { stage('Checkout') { steps { echo 'Pulling latest code...' checkout scm } } stage('Deploy') { steps { echo 'Deploying to VPS...' sshagent(['vps-ssh-key']) { sh ''' # Copy files to VPS ssh -o StrictHostKeyChecking=no root@${VPS_HOST} "mkdir -p ${BOT_DIR}" scp -o StrictHostKeyChecking=no -r * root@${VPS_HOST}:${BOT_DIR}/ # Setup and restart on VPS (force bash) ssh -o StrictHostKeyChecking=no root@${VPS_HOST} /bin/bash << 'ENDSSH' cd /srv/fymious-tg-bot # Remove corrupted venv and recreate rm -rf .venv python3 -m venv .venv # Install dependencies .venv/bin/pip install --upgrade pip .venv/bin/pip install -r requirements.txt # Restart service systemctl restart fymious-tg-bot # Check status sleep 3 systemctl is-active fymious-tg-bot ENDSSH ''' } } } } post { success { echo 'Deployment successful!' } failure { echo 'Deployment failed!' } } }