This commit is contained in:
dxin
2025-10-31 16:47:36 +08:00
parent b9f7ef980b
commit 4053c70dcc
9 changed files with 156 additions and 14 deletions

View File

@@ -1,8 +1,6 @@
pipeline {
agent any
tools{
node 'node20.15.0'
}
parameters {
gitParameter(
branchFilter: 'origin/(.*)',
@@ -19,25 +17,30 @@ pipeline {
choice(
name: 'NAME_SPACES',
choices: ['sit', 'test', 'prod'],
description: '选择构建的环境配置'
description: '选择存放镜像的仓库命名空间'
)
choice(
name: 'BUILD_ENV',
choices: ['im', 's2', 'prod'],
description: '选择构建的环境配置, 默认为 pnpm build:im 构建'
)
string(
name: 'CUSTOM_TAG',
defaultValue: '',
description: '可选:自定义镜像 Tag (字母、数字、点、下划线、短横线), 留空则自动生成 “ v+构建次数_分支名_短哈希_构建时间 ”'
description: '可选:自定义镜像 Tag (字母、数字、点、下划线、短横线), 如 v0.0.1, 留空则自动生成 “ v+构建次数_分支名_短哈希_构建时间 ”'
)
}
environment {
REGISTRY = "uswccr.ccs.tencentyun.com" // 镜像仓库地址
NAMESPACE = "lessie${params.NAME_SPACES}" // 命名空间根据choices的选择拼接
IMAGE_NAME = "flymoon-admin" // 镜像名(固定前缀)
IMAGE_NAME = "lessie-ai-web" // 镜像名(固定前缀)
CREDENTIALS_ID = "dxin_img_hub_auth" // 容器仓库凭证ID
}
stages {
stage('拉取代码') {
steps {
git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://106.53.194.199/root/web/jennie.git'
git branch: "${params.Code_branch}", credentialsId: 'fly_gitlab_auth', url: 'http://106.53.194.199/web/jennie.git'
}
}
@@ -109,9 +112,20 @@ pipeline {
}
}
stage('Maven 编译') {
stage('pnpm i&b') {
steps {
sh "cd ${WORKSPACE}/ && mvn clean install -Dmaven.test.skip=true"
script {
def buildEnv = params.BUILD_ENV // 获取参数
sh """
export PATH="/data/nvm/versions/node/v20.15.0/bin:$PATH"
echo "开始安装依赖包"
cd ${WORKSPACE}/ && rm -rf node_modules && pnpm install
echo "开始构建"
pnpm build:${buildEnv}
mv dist/main/index.html dist/
chmod -R 755 dist/
"""
}
}
}