website/Jenkinsfile
panjunjie 679061250d 更新 Jenkinsfile
更改jenkins配置
2025-08-10 21:43:29 +08:00

60 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 'NodeJS22'
}
stages {
stage('拉取代码') {
steps {
checkout scm
}
}
stage('检查Node.js版本') {
steps {
sh 'node -v' // 验证Node.js版本应输出v22.18.0
sh 'npm -v' // 验证npm版本应输出对应版本如v10.9.3
}
}
stage('安装依赖') {
steps {
sh '''
rm -rf node_modules package-lock.json
npm config set registry https://registry.npmmirror.com
npm install
# 确保postcss插件兼容
npm install postcss-px-to-viewport-8-plugin@1.1.3 --save-dev
'''
}
}
stage('构建项目') {
steps {
sh 'npm run build'
}
}
stage('部署项目') {
steps {
// 这里根据实际情况修改部署命令
sh '''
# 将dist目录拷贝到Nginx或其他Web服务器
rm -rf /data/nginx/www/fafamall/demo/*
cp -r dist/* /data/nginx/www/fafamall/demo//
'''
}
}
}
post {
success {
echo 'Vue项目部署成功'
}
failure {
echo 'Vue项目部署失败'
}
}
}