Jenkinsfile 中的 HTTP 代理导致 docker 拉取失败 "Proxy Authentication Required"

HTTP proxy in Jenkinsfile causes docker pull to fail with "Proxy Authentication Required"

这是我的示例 python 应用的 Jenkinsfile,Build a Python app with PyInstaller

pipeline {
    agent none
    environment {
        HTTP_PROXY = "http://${CORPORATE_PROXY}:${PORT}"
        HTTPS_PROXY = "http://${CORPORATE_PROXY}:${PORT}"
        NO_PROXY = "${NO_PROXY}"
    }
    stages {
        stage('Build') {
            agent {
                docker {
                    image 'python:2-alpine'
                }
            }
            steps {
                sh 'python -m py_compile sources/add2vals.py sources/calc.py'
                stash(name: 'compiled-results', includes: 'sources/*.py*')
            }
        }
    }
}

这适用于 VPN,我正试图让它在代理后面工作。 我也尝试在这里配置 Jenkins 代理 'Manage Jenkins->Manage Plugins->Advanced->HTTP Proxy Config' 并验证相同以成功。

检查构建日志时出现以下错误

+ docker pull python:2-alpine

error during connect: Post "https://docker:2376/v1.24/images/create?fromImage=python&tag=2-alpine": Proxy Authentication Required

script returned exit code 1

我尝试使用 docker args - 不行,我尝试将此图像单独拉到代理后面 - 有效。

我觉得这可能与发送凭据以构建 jenkins 管道阶段有关。 请告诉我如何添加 credentials/how 我能解决这个错误吗?

在管理凭据下包含代理并重新启动 Jenkins,仔细检查代理设置并验证外部网站以显示“成功”消息以解决问题。

重启詹金斯: http://localhost:8080/重启