From 854e5924a3a209530a5faf1d09466c2e96b52b36 Mon Sep 17 00:00:00 2001 From: jiangh277 Date: Fri, 26 Dec 2025 21:14:40 +0800 Subject: [PATCH] jenkins support --- Jenkinsfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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/' } } }