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:
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@@ -41,7 +41,6 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def workspace = sh(script: "pwd", returnStdout: true).trim()
|
def workspace = sh(script: "pwd", returnStdout: true).trim()
|
||||||
|
|
||||||
echo "当前工作空间路径: ${workspace}"
|
echo "当前工作空间路径: ${workspace}"
|
||||||
|
|
||||||
// 确保路径正确
|
// 确保路径正确
|
||||||
@@ -51,8 +50,20 @@ pipeline {
|
|||||||
sh "chmod -R 755 ${workspace}"
|
sh "chmod -R 755 ${workspace}"
|
||||||
sh "chown -R jenkins:jenkins ${workspace}"
|
sh "chown -R jenkins:jenkins ${workspace}"
|
||||||
|
|
||||||
// 使用更健壮的Docker命令
|
// 使用绝对路径挂载工作目录到容器中,并确保所有命令都在容器内执行
|
||||||
sh """docker run --rm -v ${workspace}:/app -w /app node:18-alpine sh -c 'ls -la && if [ -f package.json ]; then npm install && npm run build; else echo "package.json not found"; exit 1; fi'"""
|
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
|
||||||
|
else
|
||||||
|
echo \"package.json not found\"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user