Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56883

Docker proxy is not set if it matches the host proxy

      I found a bug that doesn't let me set the company proxy inside a docker container because it is defined on the host as well.

      environment variable on the host:

      https_proxy=mycompany.de:8080
      

       

      pipeline {
          agent {
              label 'master'
          }
          stages {
              stage('Azure Docker Image Build') {
                  steps {
                      withDockerContainer('microsoft/azure-cli') {
                          withEnv(['HTTPS_PROXY=mycompany.de:8080']) {
                              sh 'env'
                          }
                      }
                  }
              }
          }
      }
      

      I think the origin of this bug is this line: https://github.com/jenkinsci/docker-workflow-plugin/blob/648f335899c5229fb8a6e889739db9cfb15de890/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L130

      Where every enivronment variable that matches the host variables is removed.

      Currently the workaround is to explicitly set the environment variable:

      withDockerContainer(args: '-e HTTPS_PROXY=mycompany.de:8080', image: 'microsoft/azure-cli') {
          // some block
      }
      

          [JENKINS-56883] Docker proxy is not set if it matches the host proxy

          There are no comments yet on this issue.

            Unassigned Unassigned
            xaseron Michael Werner
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: