This commit is contained in:
dxin
2025-10-20 19:42:34 +08:00
parent a61ef35316
commit 6b900c4e36
6 changed files with 401 additions and 49 deletions

View File

@@ -80,7 +80,7 @@ pipeline {
// 构建镜像,添加标签信息
sh """
docker build -t ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG} \
--label "git-branch='${params.Code_branch}'" \
--label "git-branch='${formattedBranch}'" \
--label "git-commit='${GIT_COMMIT_SHORT}'" \
--label "git-author='${GIT_AUTHOR}'" \
--label "git-message='${GIT_COMMIT_MSG}'" \
@@ -134,8 +134,10 @@ pipeline {
} else {
echo "当前镜像数未超过 ${keepCount + 1} 个,无需清理"
}
echo "当前镜像数:${allImages.size()}"
sh "docker images ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} --format 'table {{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}'"
sh """
echo "当前镜像状态:"
docker images ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME} --format 'table {{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}\\t{{.Size}}'
"""
// 无论成败都登出,清理凭证
sh "docker logout ${REGISTRY}"
echo "容器仓库已登出,本地凭证已清理"
@@ -151,9 +153,6 @@ pipeline {
failure {
// 输出构建结果
echo "镜像构建失败!"
echo "镜像地址:${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG}"
echo "latest 标签地址:${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:latest"
echo "对应代码提交:${GIT_COMMIT_SHORT}${GIT_COMMIT_MSG}"
}
}
}