upd
This commit is contained in:
75
Jenkinsfile
vendored
Normal file
75
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
BOT_DIR = '/srv/fymious-tg-bot'
|
||||
VENV_DIR = '/srv/fymious-tg-bot/.venv'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
echo 'Pulling latest code...'
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Setup') {
|
||||
steps {
|
||||
echo 'Setting up virtual environment and dependencies...'
|
||||
sh '''
|
||||
# Create bot directory if it doesn't exist
|
||||
mkdir -p ${BOT_DIR}
|
||||
|
||||
# Copy files to bot directory
|
||||
cp -r * ${BOT_DIR}/
|
||||
|
||||
cd ${BOT_DIR}
|
||||
|
||||
# Create virtual environment if it doesn't exist
|
||||
if [ ! -d "${VENV_DIR}" ]; then
|
||||
python3 -m venv ${VENV_DIR}
|
||||
fi
|
||||
|
||||
# Install/update dependencies
|
||||
${VENV_DIR}/bin/pip install -r requirements.txt
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
echo 'Restarting bot...'
|
||||
sh '''
|
||||
# Kill existing bot process
|
||||
pkill -f "python.*bot.py" || true
|
||||
|
||||
# Wait a moment
|
||||
sleep 2
|
||||
|
||||
# Start bot in background
|
||||
cd ${BOT_DIR}
|
||||
nohup ${VENV_DIR}/bin/python bot.py > ${BOT_DIR}/bot.log 2>&1 &
|
||||
|
||||
# Verify bot started
|
||||
sleep 3
|
||||
if pgrep -f "python.*bot.py" > /dev/null; then
|
||||
echo "Bot started successfully!"
|
||||
else
|
||||
echo "Failed to start bot. Check logs at ${BOT_DIR}/bot.log"
|
||||
exit 1
|
||||
fi
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo 'Deployment successful!'
|
||||
}
|
||||
failure {
|
||||
echo 'Deployment failed!'
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user