title: Importing map variable to Jenkinsfile environment stage
body: <p>My project has many common variables for many other projects, so I use Jenkins Shared Library and created a <code>vars/my_vars.groovy</code> file where I defined my variables and return Map of them:</p>
  
  <pre><code>class my_vars {
      static Map varMap = [:]
      static def loadVars (Map config) {
          varMap.var1 = "val1"
          varMap.var2 = "val2"
          // Many more variables ...
  
          return varMap
      }
  }
  </code></pre>
  
  <p>I load the Shared Library in my Jenkinsfile, and call the function in the <strong>environment</strong> bullet, as I want those variables to be as environment variables .</p>
  
  <p>Jenkinsfile:</p>
  
  <pre><code>pipeline {
  
      environment {
          // initialize common vars
          common_vars = my_vars.loadVars()
      } // environment
  
      stages {
          stage('Some Stage') {
              // ...
          }
      }
  
      post {
          always { 
              script {
                  // Print environment variables
                  sh "env"
              } // script
          } // always
      } // post
  
  } // pipeline
  </code></pre>
  
  <p>The thing is that the environment bullet gets <code>KEY=VALUE</code> pairs, thus my <code>common_vars</code> map is loaded like a String value (I can see that on <code>sh "env"</code>).</p>
  
  <pre><code>...
  vars=[var1:val1, var2:val2]
  ...
  </code></pre>
  
  <p>What is the correct way to declare those values as an environment variables?
  My target to get this:</p>
  
  <pre><code>...
  var1=val1
  var2=val2
  ...
  </code></pre>