Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>Jenkins 1.x</h1> <p>The following groovy snippet should pass the version (as you've already supplied), and store it in the job's variables as 'miniVersion'.</p> <pre><code>import hudson.model.* def env = System.getenv() def version = env['currentversion'] def m = version =~/\d{1,2}/ def minVerVal = m[0]+"."+m[1] def pa = new ParametersAction([ new StringParameterValue("miniVersion", minVerVal) ]) // add variable to current job Thread.currentThread().executable.addAction(pa) </code></pre> <p>The variable will then be accessible from other build steps. e.g.</p> <pre><code>echo miniVersion=%miniVersion% </code></pre> <p>Outputs:</p> <pre><code>miniVersion=12.34 </code></pre> <p>I believe you'll need to use the "System Groovy Script" (on the Master node only) as opposed to the "Groovy Plugin" - <a href="https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin#Groovyplugin-GroovyScriptvsSystemGroovyScript">https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin#Groovyplugin-GroovyScriptvsSystemGroovyScript</a></p> <h1>Jenkins 2.x</h1> <p>I believe the previous (<strong>Jenkins 1.x</strong>) behaviour stopped working because of <a href="https://wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2016-05-11">this Security Advisory</a>...</p> <h3>Solution (paraphrased from the Security Advisory)</h3> <p>It's possible to restore the previous behaviour by setting the system property <code>hudson.model.ParametersAction.keepUndefinedParameters</code> to <code>true</code>. <strong>This is potentially very unsafe</strong> and intended as a short-term workaround only.</p> <pre><code>java -Dhudson.model.ParametersAction.keepUndefinedParameters=true -jar jenkins.war </code></pre> <p>To allow specific, known safe parameter names to be passed to builds, set the system property <code>hudson.model.ParametersAction.safeParameters</code> to a comma-separated list of safe parameter names. </p> <p><strong>e.g.</strong></p> <pre><code>java -Dhudson.model.ParametersAction.safeParameters=miniVersion,FOO,BAR -jar jenkins.war </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload