pipeline { agent any environment { BOT_DIR = '/srv/fymious-tg-bot' VPS_HOST = 'your-vps-ip-or-hostname' } 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 ssh -o StrictHostKeyChecking=no root@${VPS_HOST} << 'ENDSSH' cd ${BOT_DIR} # Create venv if needed if [ ! -d ".venv" ]; then python3 -m venv .venv fi # Install dependencies .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!' } } }