Jenkins and case sensitive environment variables

Some tools demand environment variables to be present in a certain case. E.g. some libraries read out the proxy configuration in the environment variable HTTP_PROXY (all uppercase), while some refer to the lower case variant http_proxy. An example of the later is libcurl. So in any case you want to set both variants.

Unfortunately Jenkins has some problems passing all variants from the build host environment and is mixing up things. It doesn’t seem that the problem is fixed anytime soon.

E.g. if you defined on the build host the following in /etc/environment:


The build process will see:


So regarding the variable names the last occurence is winning and regarding the values the first occurence is winning.

Its not possible to fix the environment manually in the Jenkinsfile, e.g. the following

environment {
    UPPERCASE_FIRST = "fixed in Jenkinsfile"

will nevertheless result in

uppercase_first='fixed in Jenkinsfile'

As a workaround the environment variables can be set manually in the step where they are needed:

steps {
    sh "http_proxy=$HTTP_PROXY no_proxy=$NO_PROXY download-stuff"