Kubernetes agent does not inherit from default pod template

At the end I successfully passed globally defined environment variables in Jenkins to containers by mapping the values in pipeline environment:

pipeline {
   agent {
      kubernetes {
          ...
      }
   }
   environment {
      HTTPS_PROXY="${HTTPS_PROXY}"
      HTTP_PROXY="${HTTP_PROXY}"
      NO_PROXY="${NO_PROXY}"
   }
   stages {
      stage ("build") {
         container("nodejs"){
            //env.HTTPS_PROXY available
   }
}

Good advices in working with pod templates can be found in this article:

But sometimes you don’t get around defining values globally, e.g. http proxy.

Hopefully this helps people searching undocumented features like this.

1 Like