Q: How to geta value from the map with key as variable? I have a Jenkins pipeline that consists of:
parameters.groovy
    static Map<String, String> doMapping() {
        [
                'a-b-c': '1-2-3',
                'd-e-f': '4-5-6',
                'g-h-i': '7-8-9'
        ]
    }
    return this

Jenkinsfile
    Map<String, String> myMap = null
    ...
    pipeline {
      parameters {
        string(name: 'param1')
      }
      stages {
        stage('Stage 1', {
          ...
          steps {
            script {
              myMap = load('parameters.groovy').doMapping()
            }
          }
        }
        stage('Stage 2', {
          ...
          steps {
            script {
              String p = ""
              String v = ""
              if (params.PARAM1?.trim()) {
                p = params.PARAM1
                v = myMap.get(p)
                if (v == null) { // Set v to p if not found in the map
                  v = p
                }
                echo "v = ${v}"
                v = myMap.get('d-e-f')
                if (v == null) {
                  v = p
                }
                echo "v = ${v}"
              }
            }
          }
        }
      }
    }

Input:
param1 = d-e-f

Output:
[Pipeline] echo
v = d-e-f
[Pipeline] echo
v = 4-5-6

Why is a map entry not found when variable is used as the key and is found when hardcoded?
I tried to check for empty spaces but there was none, I checked types of map keys, p, params.PARAM1 and v and they are java.lang.String.
