Parameterised build in jenkins: Not getting parameters as shell env variables
<p>Jenkins version: 2.6, Linux</p>

<p>Problem: The parameterized build variables are not are not visible (as env variables) in the Execution step "shell script", They used to be visible in the older 1.x jenkins version.</p>

<p>Steps:</p>

<ol>
<li>Create a parameterized build with a multi configuration project.</li>
<li>Add a parameter to the build (using This project is parameterized-> string parameter, {if that matters} ).</li>
<li>Add a build step "Execute shell" to the job.</li>
<li><p>Access these parameters in this shell script as env variables.</p>

<p>echo "++++++++++++ building $lib_name ($lib_version) ++++++++++++++"</p></li>
</ol>

<p>To solve this, I have tried to create a groovy script in "Prepare an environment for the run" section. I created env variables using hardcoded values which are pased to shell script as env vars.</p>

<pre><code>def map = ['lib_name':'lib1']
map['lib_version'] = 'master'
return map
</code></pre>

<p>But, without hardcoding, I cannot access these variable values even when using solution from
<a href="https://stackoverflow.com/questions/10882515/how-to-retrieve-jenkins-build-parameters-using-the-groovy-api">How to retrieve Jenkins build parameters using the Groovy API?</a></p>

<p>I dont know what else has to be done. Can some one please suggest?</p>

<p>---> Updating based on the comments on this question:
When I run the following lines in jenkins, I get exception:</p>

<pre><code>def buildVariablesMap = Thread.currentThread().executable.buildVariables 
buildVariablesMap.each{ k, v -&gt; println "${k}:${v}" }




FATAL: No such property: executable for class: hudson.model.OneOffExecutor
groovy.lang.MissingPropertyException: No such property: executable for class: hudson.model.OneOffExecutor
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
</code></pre>