You need to update the ParametersAction object of the build. I found the
solution in the following link:
https://groups.google.com/forum/#!topic/jenkinsci-users/szhuDfCvpiE. I
could not use the code exactly as written in my company's instance of
Jenkins. The ParametersAction.createUpdated method would not work for
me, perhaps because we're still on LTS 1.466.2, so I re-created its
function in my code, shown below.
Regards,
Eric
// Call the function like this:
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);
// Function definition
// sets build parameters based on the given map
// only supports StringParameterValue
def setBuildParameters(parmMap) {
def npl = new ArrayList<StringParameterValue>()
for (k in parmMap.keySet()) {
npl.add(new StringParameterValue(k, parmMap.get(k)))
}
def newPa = null
def oldPa = build.getAction(ParametersAction.class)
if (oldPa != null) {
//Re-create createUpdated method which did not work for me
for (oldp in oldPa) {
if (! parmMap.containsKey(oldp.name)) { //oldp was not
overridden by the new list
npl.add(oldp)
}
}
build.actions.remove(oldPa)
}
newPa = new ParametersAction(npl)
build.actions.add(newPa)
}
On 3/6/2014 10:32 AM, dev123 wrote:
In my plugin I need to dynamically update the values of a bunch of
String parameters that the user specified when building a job
ParametersAction params = project.getAction(ParametersAction.class);
// How do we update existing parameters?
StringParameterValue parameter = (StringParameterValue) params
.getParameter("MyParam");
// Fails since value is final :-(
parameter.value = "asd";
how do I update values of existing parameters?
--
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/groups/opt_out.
--
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.