jenkins support
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:
18
Jenkinsfile
vendored
18
Jenkinsfile
vendored
@@ -1,6 +1,9 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'node:18-alpine' // 使用包含 Node.js 的 Docker 镜像
|
||||||
|
}
|
||||||
|
}
|
||||||
environment {
|
environment {
|
||||||
// 环境变量定义
|
// 环境变量定义
|
||||||
PROJECT_NAME = 'timeline-frontend'
|
PROJECT_NAME = 'timeline-frontend'
|
||||||
@@ -25,10 +28,15 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps {
|
steps {
|
||||||
checkout scm
|
|
||||||
script {
|
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') {
|
stage('Build timeline-frontend dist') {
|
||||||
@@ -37,6 +45,8 @@ pipeline {
|
|||||||
// 确保先执行前端构建命令
|
// 确保先执行前端构建命令
|
||||||
sh 'npm install'
|
sh 'npm install'
|
||||||
sh 'npm run build' // 这会生成 dist 目录
|
sh 'npm run build' // 这会生成 dist 目录
|
||||||
|
// 验证构建产物
|
||||||
|
sh 'ls -la dist/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user