From 2b63c3f026e7f65449bbdb8a59b8b9c228a85033 Mon Sep 17 00:00:00 2001 From: jianghao <332515344@qq.com> Date: Mon, 29 Dec 2025 15:26:05 +0800 Subject: [PATCH] Jenkins build --- Jenkinsfile | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 06f0ca8..42632ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,27 +51,11 @@ pipeline { sh "chown -R jenkins:jenkins ${workspace}" // 使用绝对路径挂载工作目录到容器中,并确保所有命令都在容器内执行 - sh '''docker run --rm -v "${PWD}:/app" -w /app node:18-alpine sh -c " - echo \"Current directory contents:\" - ls -la - echo \"Checking for package.json:\" - if [ -f \"package.json\" ]; then - echo \"package.json found, proceeding with build\" - npm install - npm run build - echo \"Build completed, checking for dist directory:\" - ls -la - if [ -d \"dist\" ]; then - echo \"dist directory exists\" - else - echo \"ERROR: dist directory does not exist\" - exit 1 - fi - else - echo \"package.json not found\" - exit 1 - fi - "''' + 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 目录 + sh 'ls -la' + sh 'if [ ! -d "dist" ]; then echo "ERROR: dist directory does not exist after build"; exit 1; fi' } } }