test remote deployment

This commit is contained in:
Kimsongwu
2025-04-16 12:03:48 +08:00
parent 33ef193ff9
commit ea22a3c493
2 changed files with 20 additions and 26 deletions
Vendored
+19 -7
View File
@@ -1,16 +1,15 @@
pipeline {
agent any
// environment {
// NODEJS_HOME = '/usr/local/nodejs' // Adjust this path to your Node.js installation
// PATH = "${NODEJS_HOME}/bin:${env.PATH}"
// }
stages {
stage('📄文件信息') {
steps {
sh 'pwd'
sh 'ls -al'
echo '🚀开始推送文件到坤爷服务器'
sh 'scp Dockerfile root@47.109.22.188:~/go_fish_web'
sh 'scp nginx.conf root@47.109.22.188:~/go_fish_web'
echo '✨推送完成'
}
}
@@ -30,15 +29,28 @@ pipeline {
steps {
dir('dist') {
sh 'ls -al'
sh 'tar -zcvf gofishingweb.tar.gz *'
archiveArtifacts artifacts: 'gofishingweb.tar.gz',
sh 'tar -zcvf go_fish_web.tar.gz *'
archiveArtifacts artifacts: 'go_fish_web.tar.gz',
allowEmptyArchive: true,
fingerprint: true,
onlyIfSuccessful: true
sh 'ls -al'
echo '🚀开始推送制品到坤爷服务器'
sh 'scp go_fish_web.tar.gz root@47.109.22.188:~/go_fish_web'
echo '✨推送完成'
}
}
}
stage('🏓远程部署') {
steps {
echo '🚀开始远程部署'
sh 'ssh root@47.109.22.188 "docker stop go_fish_web && docker rmi go_fish_web && docker build -t go_fish_web ~/go_fish_web"'
sh 'ssh root@47.109.22.188 "docker run --restart=always --name go_fish_web -d -p 30030:80 -v /etc/localtime:/etc/localtime:ro go_fish_web"'
sh 'ssh root@47.109.22.188 "docker ps -a"'
echo '✨远程部署完成'
}
}
}
post {