From 3dc7da0387fd3755bd32199a9bf7ce948373700d Mon Sep 17 00:00:00 2001 From: panjunjie <46790855@qq.com> Date: Sun, 10 Aug 2025 22:26:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Jenkinsfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新jenkins 配置文件 --- Jenkinsfile | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ff67b5a..b037011 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,11 @@ pipeline { tools { nodejs 'NodeJS22' } + + environment { + // 抽取部署目标路径为公共变量 + DEPLOY_DIR = '/data/nginx/www/fafamall/website' + } stages { stage('拉取代码') { @@ -11,13 +16,6 @@ pipeline { checkout scm } } - - stage('检查Node.js版本') { - steps { - sh 'node -v' - sh 'npm -v' - } - } stage('安装依赖') { steps { @@ -38,9 +36,10 @@ pipeline { stage('部署项目') { steps { sh ''' - mkdir -p /data/nginx/www/fafamall/demo - rm -rf /data/nginx/www/fafamall/demo/* - cp -r dist/* /data/nginx/www/fafamall/demo/ + # 公共部署逻辑(创建目录、清理、复制) + mkdir -p ${DEPLOY_DIR} + rm -rf ${DEPLOY_DIR}/* + cp -r dist/* ${DEPLOY_DIR}/ ''' } } @@ -48,10 +47,10 @@ pipeline { post { success { - echo 'Vue项目部署成功' + echo 'Vue项目部署成功.' } failure { - echo 'Vue项目部署失败' + echo 'Vue项目部署失败.' } } } \ No newline at end of file