Merge branch 'main' of http://git.gpxscs.cn/front/website
This commit is contained in:
commit
6b5516f5f9
36
Jenkinsfile
vendored
Normal file
36
Jenkinsfile
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
DEPLOY_DIR = '/data/nginx/www/fafamall/website'
|
||||
DIST_PATH = 'dist'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('拉取代码并验证') {
|
||||
steps {
|
||||
checkout scm
|
||||
sh """
|
||||
[ -d "${DIST_PATH}" ] || { echo "错误:未找到 ${DIST_PATH} 文件夹"; exit 1; }
|
||||
echo "${DIST_PATH} 验证通过"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('部署') {
|
||||
steps {
|
||||
sh """
|
||||
mkdir -p ${DEPLOY_DIR}
|
||||
rm -rf ${DEPLOY_DIR}/*
|
||||
cp -r ${DIST_PATH}/* ${DEPLOY_DIR}/
|
||||
echo "部署完成:${DIST_PATH} → ${DEPLOY_DIR}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success { echo "✅ 部署成功" }
|
||||
failure { echo "❌ 部署失败" }
|
||||
}
|
||||
}
|
||||
56
JenkinsfileBuild
Normal file
56
JenkinsfileBuild
Normal file
@ -0,0 +1,56 @@
|
||||
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项目部署失败.'
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user