Jenkins build
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit

This commit is contained in:
2025-12-29 15:41:20 +08:00
parent 60c3cd2332
commit 18fa62f6be

35
Jenkinsfile vendored
View File

@@ -45,19 +45,32 @@ pipeline {
// 确保路径正确 // 确保路径正确
sh "ls -la ${workspace}" sh "ls -la ${workspace}"
sh "npm -v"
sh "npm install && npm run build"
// 修复权限问题 // 使用 Jenkins Node.js 插件
// sh "chmod -R 755 ${workspace}" nodejs('NodeJS-18') {
// sh "chown -R jenkins:jenkins ${workspace}" // 检查是否存在 package.json
// if (fileExists('package.json')) {
// // 使用绝对路径挂载工作目录到容器中,并确保所有命令都在容器内执行 echo "package.json found"
// sh 'docker run --rm -v "${PWD}:/app" -w /app node:18-alpine sh -c \'if [ -f "package.json" ]; then echo "package.json found"; npm install && npm run build; else echo "package.json not found"; exit 1; fi\''
// 检查构建是否生成了 dist 目录 // 安装 pnpm
sh 'ls -la' sh 'npm install -g pnpm'
sh 'if [ ! -d "dist" ]; then echo "ERROR: dist directory does not exist after build"; exit 1; fi'
// 使用 pnpm 安装依赖
sh 'pnpm install --frozen-lockfile'
// 构建项目
sh 'pnpm run build'
// 检查 dist 目录是否存在
if (!fileExists('dist')) {
error('ERROR: dist directory does not exist after build')
} else {
echo 'Build completed successfully, dist directory exists'
}
} else {
error('package.json not found')
}
}
} }
} }
} }