Files
fymious-tg-bot/Jenkinsfile
2026-01-27 14:45:48 +03:00

60 lines
1.8 KiB
Groovy

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
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!'
}
}
}