Files
tra-app/Jenkinsfile
T
2026-03-28 21:25:06 +08:00

96 lines
2.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 'node22'
}
stages {
stage('打印环境变量') {
steps {
echo "使用的凭据ID${env.BRANCH_NAME}"
}
}
stage('清理旧构建') {
steps {
sh '''
# 清理 uniapp 上次打包产物
rm -rf dist/
# 清理安卓构建缓存
rm -rf android/simpleDemo/build/
'''
}
}
// 修复 npm 权限 + 设置国内镜像
stage('修复npm权限') {
steps {
sh '''
# 配置 npm 缓存目录到当前工作区(解决权限问题)
npm config set cache $WORKSPACE/.npm
npm config set prefix $WORKSPACE/.npm-global
npm config set registry https://registry.npmmirror.com
'''
}
}
stage('安装依赖') {
steps {
sh 'npm install'
}
}
stage('打包uniapp') {
steps {
sh 'npm run build:app-plus:${env.BRANCH_NAME}'
}
}
//
// stage('构建 & 测试') {
// steps {
// sh 'mvn clean package -DskipTests'
// sh 'mvn test'
// }
// // 构建产物归档
// post {
// success {
// archiveArtifacts artifacts: 'target/*.jar', followSymlinks: false
// }
// }
// }
//
// stage('构建 Docker 镜像') {
// steps {
// sh 'docker build -t myapp:${BUILD_NUMBER} .'
// }
// }
//
// stage('推送镜像') {
// steps {
// sh '''
// docker login -u ${DOCKER_CREDS_USR} -p ${DOCKER_CREDS_PSW}
// docker push myapp:${BUILD_NUMBER}
// '''
// }
// }
//
// stage('部署到服务器') {
// steps {
// sh 'docker stop myapp && docker rm myapp || true'
// sh 'docker run -d -p 8080:8080 --name myapp myapp:${BUILD_NUMBER}'
// }
// }
}
post {
always {
echo '流水线已结束'
}
success {
echo '🎉 项目部署成功!'
}
failure {
echo '⚠️ 部署失败,请检查日志!'
}
}
}