I found a solution to this.
You have to get the 'Actions' of the build using the getActions() call,
find the ParametersAction and remove it, then create a new set of
parameters and then add them as an Action.
On Monday, 6 August 2012 11:43:00 UTC+1, Reuben Gow wrote:
>
> Hi Chris,
>
> I've tried out the EnvInject plugin but it doesn't seem to be able to
> overwrite existing variables.
>
> if I put:
>
> return [ SOME_NEW_VAR: "blah" ]
>
>
> then I can put the following the in the build step
>
> echo ${SOME_NEW_VAR}
>
>
> and get the correct value.
>
> However if I put:
>
> return [ version_number: "blah" ]
>
>
> where version_number is one of the build parameters the echo command
> returns the original passed in parameter.
>
>
> On Friday, 3 August 2012 17:38:32 UTC+1, cjo wrote:
>>
>> Have a look at the EnvInject Plugin[1], to see if you are able plug your
>> script into it and get the correct results.
>> look at "Prepare an environment for the run" section in the job config.
>>
>> The "Evaluated Groovy script" item might override them correctly.
>>
>> https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
>>
>> Chris
>>
>> On Friday, August 3, 2012 4:52:17 PM UTC+1, Reuben Gow wrote:
>>>
>>> Hi,
>>>
>>> I have a job that takes a number of parameters (version_number,
>>> release_number, branch etc). This build can be built in a number of ways,
>>> some need to get the values of these parameters from other locations. the
>>> different modes are:
>>>
>>> 1) Manually - Take the passed in parameters
>>> 2) SCM Change - take the parameter values from the last successful build
>>> of another job
>>> 3) Timer - take the parameter values from the last successful build of
>>> another job
>>> 4) Upstream Job - take the parameters passed to it from the upstream job.
>>>
>>> 1 is obviously no problem, as is 4 with the use of the Parameterized
>>> build plugin.
>>>
>>> I have written a Groovy script to retrieve the parameter values for
>>> cases 2 and 3 but can't find a way to apply these values to the variables
>>> used in the build step (execute shell ). I can create new parameters and
>>> access these as variables but I don't really like this method as it makes
>>> my shell script a bit ugly.
>>>
>>> Does anyone know how to overwrite parameter values from within the
>>> Groovy script.
>>>
>>> Thanks
>>>
>>