更新 Jenkinsfile
更新jenkins 配置文件
This commit is contained in:
parent
67f0cf87cb
commit
3dc7da0387
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -4,6 +4,11 @@ pipeline {
|
|||||||
tools {
|
tools {
|
||||||
nodejs 'NodeJS22'
|
nodejs 'NodeJS22'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
// 抽取部署目标路径为公共变量
|
||||||
|
DEPLOY_DIR = '/data/nginx/www/fafamall/website'
|
||||||
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('拉取代码') {
|
stage('拉取代码') {
|
||||||
@ -11,13 +16,6 @@ pipeline {
|
|||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('检查Node.js版本') {
|
|
||||||
steps {
|
|
||||||
sh 'node -v'
|
|
||||||
sh 'npm -v'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('安装依赖') {
|
stage('安装依赖') {
|
||||||
steps {
|
steps {
|
||||||
@ -38,9 +36,10 @@ pipeline {
|
|||||||
stage('部署项目') {
|
stage('部署项目') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
mkdir -p /data/nginx/www/fafamall/demo
|
# 公共部署逻辑(创建目录、清理、复制)
|
||||||
rm -rf /data/nginx/www/fafamall/demo/*
|
mkdir -p ${DEPLOY_DIR}
|
||||||
cp -r dist/* /data/nginx/www/fafamall/demo/
|
rm -rf ${DEPLOY_DIR}/*
|
||||||
|
cp -r dist/* ${DEPLOY_DIR}/
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,10 +47,10 @@ pipeline {
|
|||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
echo 'Vue项目部署成功'
|
echo 'Vue项目部署成功.'
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo 'Vue项目部署失败'
|
echo 'Vue项目部署失败.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user