From 53f5cd19ee726d3b772ad377bf12901b27ea4fea Mon Sep 17 00:00:00 2001 From: panjunjie <46790855@qq.com> Date: Mon, 11 Aug 2025 18:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20JenkinsfileBuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JenkinsfileBuild | 57 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/JenkinsfileBuild b/JenkinsfileBuild index 9d60796..b037011 100644 --- a/JenkinsfileBuild +++ b/JenkinsfileBuild @@ -1 +1,56 @@ -11 \ No newline at end of file +pipeline { + agent any + + tools { + nodejs 'NodeJS22' + } + + environment { + // 抽取部署目标路径为公共变量 + DEPLOY_DIR = '/data/nginx/www/fafamall/website' + } + + stages { + stage('拉取代码') { + steps { + checkout scm + } + } + + stage('安装依赖') { + steps { + sh ''' + rm -rf node_modules package-lock.json + npm config set registry https://registry.npmmirror.com + npm install + ''' + } + } + + stage('构建项目') { + steps { + sh 'npm run build' + } + } + + stage('部署项目') { + steps { + sh ''' + # 公共部署逻辑(创建目录、清理、复制) + mkdir -p ${DEPLOY_DIR} + rm -rf ${DEPLOY_DIR}/* + cp -r dist/* ${DEPLOY_DIR}/ + ''' + } + } + } + + post { + success { + echo 'Vue项目部署成功.' + } + failure { + echo 'Vue项目部署失败.' + } + } +} \ No newline at end of file