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

Viewed 208

Here is my Jenkinsfile for a sample python app, 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*')
            }
        }
    }
}

This works off of VPN, I am trying to make it work behind proxy. I have tried to configure Jenkins proxy here too 'Manage Jenkins->Manage Plugins->Advanced->HTTP Proxy Config' and Validated the same to SUCCESS.

I get following error when I check Build logs

+ 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

I tried using docker args - no go, I tried to pull this image separately behind proxy - works.

I feel maybe it has to do something with sending credentials to build stage of jenkins pipeline. please advise on how do I add credentials/how do I address this error?

1 Answers

included proxy under manage credentials and did Jenkins restart, Double check proxy setup and validate external website to show "Success" message to fix the issue.

To restart Jenkins: http://localhost:8080/restart

Related