pipeline { agent any environment { CODE_BRANCH = "dev" LOCKHOST_IP = "192.168.70.15" LOCKHOST_PROJECT_PATH = "/data/webapps/lessie-oficial" // 本地机器项目路径 } stages { stage('拉取代码') { steps { git branch: "${CODE_BRANCH}", credentialsId: 'fly_gitlab_auth', url: 'http://172.24.16.20/web/scalelink-frontend.git' } } stage('同步到本地机器') { steps { sh """ rsync -avz ${WORKSPACE}/ ${LOCKHOST_IP}:${LOCKHOST_PROJECT_PATH}/ """ } } stage('依赖和构建') { steps { sh """ ssh ${LOCKHOST_IP} 'bash -lc " cd ${LOCKHOST_PROJECT_PATH}/projects/lessie && bash && pnpm install && pnpm build "' """ } } stage('启动') { steps { sh """ ssh ${LOCKHOST_IP} 'bash -lc " cd ${LOCKHOST_PROJECT_PATH}/projects/lessie && bash && pm2 list && pm2 delete lessie-official-web && pm2 start .output/server/index.mjs --name lessie-official-web --output ./nuxt-out.log --error ./nuxt-error.log && pm2 list "' """ } } } }