java-mall-admin/Jenkinsfile
panjunjie 4fe6b28e81 更新 Jenkinsfile
发布时屏蔽了 vab-contextmenu 这个包,原因是该包被检测到存在恶意行为(如窃取环境变量、删除文件等)。
2025-08-11 01:50:47 +08:00

64 lines
1.5 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pipeline {
agent any
tools {
nodejs 'NodeJS16'
}
environment {
// 抽取部署目标路径为公共变量
DEPLOY_DIR = '/data/nginx/www/fafamall/demo'
}
stages {
stage('拉取代码') {
steps {
checkout scm
}
}
stage('安装依赖') {
steps {
sh '''
rm -rf node_modules package-lock.json
npm config set registry https://registry.npmmirror.com
# 检查并移除恶意依赖
if grep -q "vab-contextmenu" package.json; then
echo "发现恶意依赖vab-contextmenu正在移除..."
npm uninstall vab-contextmenu
fi
# 安装其他依赖
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 '项目部署成功.'
}
failure {
echo '项目部署失败.'
}
}
}