- 在 Jenkins 构建成功后,通过 curl 发送消息到 Telegram - 通知内容为"传奇服务端构建完成!" - 使用了特定的 bot token 和 chat_id
45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('拉取代码') {
|
|
steps {
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
branches: [[name: '*/master']],
|
|
doGenerateSubmoduleConfigurations: false,
|
|
extensions: [],
|
|
submoduleCfg: [],
|
|
userRemoteConfigs: [[url: 'http://192.168.25.110:8999/kubbo/chuanqi-server.git',credentialsId:'d54e1035-acca-424e-80d0-9f7e29cab9c3']]
|
|
])
|
|
}
|
|
}
|
|
stage('部署') {
|
|
steps {
|
|
echo 'Deploying...'
|
|
sh "cp -rf server /home/cq/data/server"
|
|
sh "cp -f run.sh /home/cq/data/run.sh"
|
|
sh "cp -f stop.sh /home/cq/data/stop.sh"
|
|
sh "cp -rf wch /home/cq/data/wch"
|
|
sh "docker restart chuanqi-server"
|
|
sh "docker exec -itd chuanqi-server bash -- /data/run.sh"
|
|
}
|
|
}
|
|
}
|
|
post{
|
|
success {
|
|
echo 'Deployment finished successfully.'
|
|
sh """
|
|
curl 'https://api.telegram.org/bot7816434196:AAFtmbUYpUIwcb_SvBnJY0guPIOLCxp2a5s/sendMessage?key=1e734bc6-ab12-4272-8b15-cf92cb070f5b' \\
|
|
-H 'Content-Type: application/json' \\
|
|
-d '{
|
|
"chat_id": "6779541681",
|
|
"text":"传奇服务端构建完成!",
|
|
}'
|
|
"""
|
|
}
|
|
failure {
|
|
echo 'Deployment failed.'
|
|
}
|
|
}
|
|
}
|