lawless-design/Jenkinsfile

50 行
1.5 KiB
Plaintext

2026-07-09 14:39:17 +08:00
pipeline {
agent any
environment {
PROD_HOST = '106.54.23.149'
PROD_USER = 'ubuntu'
DEPLOY_DIR = '/var/www/docs.xuqinmin.com/site'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build Docs') {
steps {
2026-07-09 14:56:39 +08:00
powershell '''
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$env:PYTHONIOENCODING = 'utf-8'
$env:PYTHONUTF8 = '1'
pip3 install mkdocs-material --quiet 2>$null || Write-Host 'ok'
python -X utf8 -m mkdocs build --clean --site-dir site
'''
2026-07-09 14:39:17 +08:00
}
}
stage('Deploy') {
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'PROD_SSH_KEY', keyFileVariable: 'SSH_KEY')]) {
bat '''
ssh -i %SSH_KEY% -o StrictHostKeyChecking=no -o ConnectTimeout=30 %PROD_USER%@%PROD_HOST% "mkdir -p %DEPLOY_DIR% && sudo rm -rf %DEPLOY_DIR%/* && sudo chown -R %PROD_USER%:%PROD_USER% %DEPLOY_DIR%"
2026-07-09 14:39:17 +08:00
scp -i %SSH_KEY% -o StrictHostKeyChecking=no -o ConnectTimeout=30 -r site/* %PROD_USER%@%PROD_HOST%:%DEPLOY_DIR%/
'''
}
}
}
}
post {
success {
echo 'Docs deployed: https://docs.xuqinmin.com/'
}
failure {
echo 'Docs deployment failed!'
}
}
}