Jenkins build
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit
Some checks failed
test/timeline-frontend/pipeline/head There was a failure building this commit
This commit is contained in:
35
Jenkinsfile
vendored
35
Jenkinsfile
vendored
@@ -45,19 +45,32 @@ pipeline {
|
||||
|
||||
// 确保路径正确
|
||||
sh "ls -la ${workspace}"
|
||||
sh "npm -v"
|
||||
sh "npm install && npm run build"
|
||||
|
||||
// 修复权限问题
|
||||
// sh "chmod -R 755 ${workspace}"
|
||||
// sh "chown -R jenkins:jenkins ${workspace}"
|
||||
//
|
||||
// // 使用绝对路径挂载工作目录到容器中,并确保所有命令都在容器内执行
|
||||
// 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\''
|
||||
// 使用 Jenkins Node.js 插件
|
||||
nodejs('NodeJS-18') {
|
||||
// 检查是否存在 package.json
|
||||
if (fileExists('package.json')) {
|
||||
echo "package.json found"
|
||||
|
||||
// 检查构建是否生成了 dist 目录
|
||||
sh 'ls -la'
|
||||
sh 'if [ ! -d "dist" ]; then echo "ERROR: dist directory does not exist after build"; exit 1; fi'
|
||||
// 安装 pnpm
|
||||
sh 'npm install -g pnpm'
|
||||
|
||||
// 使用 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')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user