It's true - you can't actually update a parameter list in-place. You have to create a new one to replace the old one. Here's how I did it, based on some code I found from a 2012 question <https://groups.google.com/forum/#%21topic/jenkinsci-users/szhuDfCvpiE> on this group. This code will update existing parameters.

def setBuildParameters(parmMap) {
  // only supports StringParameterValue
  def npl = new ArrayList<StringParameterValue>()
  for (k in parmMap.keySet()) {
     npl.add(new StringParameterValue(k, parmMap.get(k)))
  }//end for
  def newPa = null
  def oldPa = build.getAction(ParametersAction.class)

  if (oldPa != null) {
    for (oldp in oldPa) {
if (! parmMap.containsKey(oldp.name)) { //oldp was not overridden by the new list
        npl.add(oldp)
      }//end if
    }//end for
    build.actions.remove(oldPa)
  }//end if
  newPa = new ParametersAction(npl)
  build.actions.add(newPa)
}

new_params = new java.util.HashMap();
new_params.put('INSTALL_HOME',install_home);
new_params.put('COMPILER',compiler);
new_params.put('COMPILER_OPT',compiler_opt);
setBuildParameters(new_params);





On 10/22/2014 1:36 PM, Ginga, Dick wrote:

I am admittedly a novice at Groovy but this script does not complain about the "put" operation but does not apparently perform it:

label-name is a parameter in that build.

*Dick Ginga, Informatics R&D*

*PerkinElmer Inc. **| For the Better
**HUMAN HEALTH **|****ENVIRONMENTAL HEALTH*
940 Winter Street, Waltham MA 02451

[email protected] <mailto:[email protected]>_

Mobile -- 508-847-1434

Office -- 781-663-6947

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jenkins 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to