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:47:36 +08:00
parent 07d1eb553c
commit 3d7ab7c6af

43
Jenkinsfile vendored
View File

@@ -46,27 +46,40 @@ pipeline {
// 确保路径正确
sh "ls -la ${workspace}"
// 使用 Jenkins Node.js 插件
nodejs('NodeJS-18') {
// 检查是否存在 package.json
if (fileExists('package.json')) {
echo "package.json found"
// 修复权限问题
sh "chmod -R 755 ${workspace}"
sh "chown -R jenkins:jenkins ${workspace}"
// 使用 Jenkins Node.js 插件,并确保在工作空间目录中执行
dir(workspace) {
nodejs('NodeJS-18') {
// 检查是否存在 package.json 和 pnpm-lock.yaml
if (fileExists('package.json')) {
echo "package.json found"
if (fileExists('pnpm-lock.yaml')) {
echo "pnpm-lock.yaml found"
} else {
error('pnpm-lock.yaml not found')
}
// 使用 pnpm 安装依赖
sh 'npm install'
// 安装 pnpm
sh 'npm install -g pnpm'
// 构建项目
sh 'npm run build'
// 使用 pnpm 安装依赖,使用 --frozen-lockfile 确保依赖一致性
sh 'pnpm install --frozen-lockfile'
// 检查 dist 目录是否存在
if (!fileExists('dist')) {
error('ERROR: dist directory does not exist after build')
// 构建项目
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 {
echo 'Build completed successfully, dist directory exists'
error('package.json not found')
}
} else {
error('package.json not found')
}
}
}