title: Get global variables from map
body: <p>I would like to have a groovy file for my Jenkins pipeline shared library that would store several keys with default values and be able to call and get the value of individual keys from other functions in different groovy functions such as <em>test.groovy</em>. I am not sure how I should or can structure the groovy file.</p>
  
  <p>/vars/settings.groovy</p>
  
  <pre><code>def configuration = [
      artifactoryURL: 'artifactory.example.com',                          
      daysToKeep: 14,                                             
      maxRetry: 3 ]
  </code></pre>
  
  <p>/var/test.groovy</p>
  
  <pre><code>globalVariables.get('artifactoryURL')   // I would like this to return "artifactory.example.com"
  </code></pre>
  
  <p>Any help would be appreciated. </p>
  
  <p><strong>Update:</strong></p>
  
  <p>I got this to work as follows:</p>
  
  <pre><code>/vars/settings.groovy
  
  #!/usr/bin/groovy
  def getConfig() {
  def config = [
      artifactoryURL: 'artifactory.example.com',
      daysToKeep: 14,
      maxRetry: 3
  ]
  return config
  }
  
  def getValue(name) {
      return config[name]
  }
  
  
  /vars/retrieveValue.groovy
  
  ...
  echo "value is " + settings.getConfig()
  echo "new value is " + settings.getValue('artifactoryURL')
  ...
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>value is [artifactoryURL:artifactory.example.com, daysToKeep:14, maxRetry:3]
  new value is artifactory.example.com
  </code></pre>
  
  <p>Is this correct syntax?
  Is there a way to simplify these?</p>