2-2同步
This commit is contained in:
@@ -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}'" \
|
||||
|
||||
@@ -16,7 +16,7 @@ pipeline {
|
||||
name: 'IMAGE_NAME',
|
||||
description: 'sit 仓库镜像 (除非输入 CUSTOM_IMAGE, 否则使用这里的)',
|
||||
registry: 'https://uswccr.ccs.tencentyun.com',
|
||||
image: 'lessiesit/lessie-review-service',
|
||||
image: 'lessiesit/lessie-email',
|
||||
credentialId: 'dxin_img_hub_auth',
|
||||
filter: '.*',
|
||||
defaultTag: '',
|
||||
@@ -26,7 +26,7 @@ pipeline {
|
||||
string(
|
||||
name: 'CUSTOM_IMAGE',
|
||||
defaultValue: '',
|
||||
description: '手输完整镜像<registry>/<namespace>/<repo>:<tag>,例如: uswccr.ccs.tencentyun.com/lessiesit/lessie-sourcing-agents:v0.0.1 (填充后,则忽略镜像仓库选择)'
|
||||
description: '手输完整镜像<registry>/<namespace>/<repo>:<tag>,例如: uswccr.ccs.tencentyun.com/lessiesit/lessie-email:v0.0.1 (填充后,则忽略镜像仓库选择)'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'ROLLBACK_VERSION',
|
||||
@@ -42,11 +42,11 @@ pipeline {
|
||||
environment {
|
||||
LARK_ROBOT = "4b8d66d0-c0f0-4587-b0e5-cff772cb3046" // 飞书机器人ID,用于发送部署通知
|
||||
KUBECONFIG = credentials('k8s-test-config-admin') // k8s 凭证 ID, Jenkins 中配置的凭证名称
|
||||
Deployment_yaml = "${WORKSPACE}/lessie-ai/sit/s1/lessie-review-service.yaml"
|
||||
Deployment_name = "sit-lessie-review-service"
|
||||
Deployment_yaml = "${WORKSPACE}/lessie-ai/sit/s1/lessie-email.yaml"
|
||||
Deployment_name = "s1-lessie-email"
|
||||
K8s_namespace = "sit"
|
||||
Pod_container_name = "lessie-review-service"
|
||||
Pod_environment = "sit"
|
||||
Pod_container_name = "lessie-email"
|
||||
Pod_environment = "s1"
|
||||
}
|
||||
stages {
|
||||
stage('回滚上版') {
|
||||
@@ -86,7 +86,7 @@ pipeline {
|
||||
def matcher = (customImage =~ imageRegex)
|
||||
if (!matcher.matches()) {
|
||||
error "CUSTOM_IMAGE 格式不正确,必须是 registry/namespace/repository:tag 格式\n" +
|
||||
"示例: uswccr.ccs.tencentyun.com/lessiesit/lessie-sourcing-agents:v1.0.0\n" +
|
||||
"示例: uswccr.ccs.tencentyun.com/lessie-ai-web:v1.0.0\n" +
|
||||
"当前输入: ${customImage}"
|
||||
}
|
||||
|
||||
@@ -188,21 +188,25 @@ pipeline {
|
||||
sh """
|
||||
echo "--- Deployment 状态 ---"
|
||||
kubectl describe deployment ${Deployment_name} -n ${K8s_namespace} || true
|
||||
echo " "
|
||||
|
||||
echo '--- Pod 列表 ---'
|
||||
kubectl get pods -n ${K8s_namespace} -l "app=${Pod_container_name},environment=${Pod_environment}" -o wide || true
|
||||
echo " "
|
||||
|
||||
echo "--- Pod 描述 (describe) ---"
|
||||
for pod in \$(kubectl get pods -n ${K8s_namespace} -l "app=${Pod_container_name},environment=${Pod_environment}" -o jsonpath='{.items[*].metadata.name}'); do
|
||||
echo "-- Pod 描述 \$pod --"
|
||||
kubectl describe pod \$pod -n ${K8s_namespace} || true
|
||||
done
|
||||
|
||||
echo " "
|
||||
|
||||
echo "--- 最近 200 行 Pod 日志 ---"
|
||||
for pod in \$(kubectl get pods -n ${K8s_namespace} -l "app=${Pod_container_name},environment=${Pod_environment}" -o jsonpath='{.items[*].metadata.name}'); do
|
||||
echo "-- logs \$pod --"
|
||||
kubectl logs \$pod -n ${K8s_namespace} --tail=200 || true
|
||||
done
|
||||
echo " "
|
||||
"""
|
||||
error("=== Deployment 发布失败,请检查以上输出定位问题 ===")
|
||||
}
|
||||
Reference in New Issue
Block a user