2-2同步

This commit is contained in:
2026-02-02 00:56:16 +08:00
parent 03e175b47c
commit 8ffe3e0e15
5 changed files with 99 additions and 69 deletions

View File

@@ -38,7 +38,7 @@ pipeline {
)
choice(
name: 'BUILD_ENV',
choices: ['im', 's2', 'prod'],
choices: ['im', 'prod'],
description: '选择构建的环境配置, 默认为 pnpm build:im 构建'
)
string(
@@ -97,6 +97,8 @@ pipeline {
stage('获取信息') {
steps {
script {
def cause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
env.ACTUAL_USER = cause ? cause.userName[0] : "系统/自动触发"
// 获取分支名
env.Code_branch = "${params.Code_branch}"
// 获取最近一次提交的哈希值短格式前8位
@@ -170,23 +172,6 @@ pipeline {
}
}
stage('pnpm i&b') {
steps {
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/
"""
}
}
}
stage('登录容器') {
steps {
withCredentials([usernamePassword(
@@ -206,7 +191,7 @@ pipeline {
script {
// 构建镜像,添加标签信息
sh """
docker build -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG} \
docker build -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG} --build-arg BUILD_ENV=${params.BUILD_ENV} \
--label "git-branch='${Code_branch}'" \
--label "git-commit='${GIT_COMMIT_SHORT}'" \
--label "git-author='${GIT_AUTHOR}'" \