更新 Jenkinsfile

更新jenkins 配置文件
This commit is contained in:
panjunjie 2025-08-10 22:26:57 +08:00
parent 67f0cf87cb
commit 3dc7da0387

23
Jenkinsfile vendored
View File

@ -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项目部署失败.'
}
}
}