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

Jenkins doesn't handle system wide environment variables which exist in different cases

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • core
    • None
    • Ubuntu 12.04 x86

      If system-wide environment variables have been set via /etc/environment those are not accessible if they exist in lower-case and capital case letters. Jenkins combines both variables into a single one, and updates the first detected variable with the value of the second one. Here some examples:

      Example 1:

      /etc/environment
      http_proxy=http://proxy.dmz.example.org:8080
      HTTP_PROXY=http://proxy.dmz.example.org:8080

      -> Jenkins:
      HTTP_PROXY=http://proxy.dmz.example.org:8080

      Example 2:

      Shell:
      export test=1
      export TEST=2

      -> Jenkins
      TEST=1

      Jenkins should not modify set environment variables because it will cause problems with tools which rely on the right capitalization. One example is mercurial which needs the lower case version of the proxy configuration. It will no longer work when both variables are set.

          [JENKINS-16255] Jenkins doesn't handle system wide environment variables which exist in different cases

          ikedam added a comment -

          I verified that not using CaseInsensitiveComparator.INSTANCE resolves the problem.

          ikedam added a comment - I verified that not using CaseInsensitiveComparator.INSTANCE resolves the problem.

          ikedam added a comment -

          Sent a pull request: https://github.com/jenkinsci/jenkins/pull/985
          But this conflicts with JENKINS-19926, b95f2694529d22523701e8fe20f4f20b2f4d9fc4 .
          I should know what that commit does.

          ikedam added a comment - Sent a pull request: https://github.com/jenkinsci/jenkins/pull/985 But this conflicts with JENKINS-19926 , b95f2694529d22523701e8fe20f4f20b2f4d9fc4 . I should know what that commit does.

          ikedam added a comment -

          I should re-fix JENKINS-19488 and JENKINS-19926 in JENKINS-20280.

          ikedam added a comment - I should re-fix JENKINS-19488 and JENKINS-19926 in JENKINS-20280 .

          ikedam added a comment -

          My pull request must be resent after https://github.com/jenkinsci/jenkins/pull/986 , JENKINS-20280 is accepted.

          ikedam added a comment - My pull request must be resent after https://github.com/jenkinsci/jenkins/pull/986 , JENKINS-20280 is accepted.

          ikedam added a comment -

          ikedam added a comment - I sent a new pull request. https://github.com/jenkinsci/jenkins/pull/988

          Rob Hetzler added a comment -

          Re-raising. this is a problem in jenkins 2.0 as well

          Rob Hetzler added a comment - Re-raising. this is a problem in jenkins 2.0 as well

          Johan Smolinski added a comment - - edited

          I believe I am affected by this issue. My problem is that the $http_proxy is removed, and only $HTTP_PROXY is kept. I am using a pipeline with this stage:

          stage('curly') {
              sh 'http_proxy=$HTTP_PROXY curl http://example.com/'
          }
          

          This works fine, as I have applied my workaround http_proxy=$HTTP_PROXY, but otherwise the $http_proxy is removed. Using jenkins 2.46.1 on GNU/Linux, openjdk 1.8.

          Johan Smolinski added a comment - - edited I believe I am affected by this issue. My problem is that the $http_proxy is removed, and only $HTTP_PROXY is kept. I am using a pipeline with this stage: stage( 'curly' ) { sh 'http_proxy=$HTTP_PROXY curl http: //example.com/' } This works fine, as I have applied my workaround http_proxy=$HTTP_PROXY, but otherwise the $http_proxy is removed. Using jenkins 2.46.1 on GNU/Linux, openjdk 1.8.

          Panagiotis Galatsanos added a comment - - edited

          and a simple test reproducing this issue: https://gist.github.com/godfath3r/d16e1a0e5beebd912344d55fb9ae9709

          Panagiotis Galatsanos added a comment - - edited and a simple test reproducing this issue: https://gist.github.com/godfath3r/d16e1a0e5beebd912344d55fb9ae9709

          James Nord added a comment - This is by design as per https://javadoc.jenkins.io/hudson/EnvVars.html#:~:text=So%20for%20a%20consistent%20cross%20platform%20behavior%2C%20it%20creates%20the%20least%20confusion%20to%20make%20the%20table%20case%20insensitive%20but%20case%20preserving

          James Nord added a comment -

          This is not a bug but the design choice from the early 21st century, and changing it would be problematic as it would be impactful.

          Whilst that is not to say that there could not be a future improvement to handle environment variables in a different way, it needs to be done carefully and would probably necessitate a new API. So closing this bug - and any future improvement would need to be tackled under a different ticket.

          James Nord added a comment - This is not a bug but the design choice from the early 21st century, and changing it would be problematic as it would be impactful. Whilst that is not to say that there could not be a future improvement to handle environment variables in a different way, it needs to be done carefully and would probably necessitate a new API. So closing this bug - and any future improvement would need to be tackled under a different ticket.

            Unassigned Unassigned
            whimboo Henrik Skupin
            Votes:
            13 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: