diff --git a/Jenkinsfile b/Jenkinsfile index dcf5398..8275df4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,9 @@ pipeline { - agent any - + agent { + docker { + image 'node:18-alpine' // 使用包含 Node.js 的 Docker 镜像 + } + } environment { // 环境变量定义 PROJECT_NAME = 'timeline-frontend' @@ -25,10 +28,15 @@ pipeline { stages { stage('Checkout') { steps { - checkout scm script { - echo "当前分支: ${params.BRANCH_NAME}" + if (params.GIT_COMMIT) { + checkout scm + sh "git reset --hard ${params.GIT_COMMIT}" + } else { + checkout scm + } } + echo "当前构建的 Git Commit: ${env.GIT_COMMIT}" } } stage('Build timeline-frontend dist') { @@ -37,6 +45,8 @@ pipeline { // 确保先执行前端构建命令 sh 'npm install' sh 'npm run build' // 这会生成 dist 目录 + // 验证构建产物 + sh 'ls -la dist/' } } }