更新
This commit is contained in:
@@ -180,6 +180,13 @@ class ContainerBuildService implements Serializable {
|
||||
try {
|
||||
// 使用Docker Pipeline插件连接到镜像仓库并进行构建推送
|
||||
script.docker.withRegistry("https://${params.registry}", params.registryCredential) {
|
||||
// ✅ 关键:把 Jenkins 注入的 ~/.docker/config.json 内容导出为环境变量
|
||||
// BuildKit 会优先读取 DOCKER_AUTH_CONFIG,而不是磁盘上的 config.json
|
||||
script.sh '''
|
||||
export DOCKER_AUTH_CONFIG=$(cat ~/.docker/config.json)
|
||||
echo "DOCKER_AUTH_CONFIG 已设置,长度: ${#DOCKER_AUTH_CONFIG}"
|
||||
'''
|
||||
|
||||
// 构建Docker镜像
|
||||
// 镜像名称格式: {命名空间}/{项目名称}:{标签}
|
||||
def dockerImage = script.docker.build(
|
||||
|
||||
Reference in New Issue
Block a user