Hello,

I was wondering how should I achieve the below. Tried few things but not 
getting anywhere

Scene:
I have a parameterized multijob project with parameter 'X=yes' and two 
multijob phases (a and b).
I want that when 'a' runs, it should modify parameter 'X' of parent and set 
it to 'X=no' after checking a condition. Then I only run b if 'X=yes' (i.e 
use enable-condition within multijob phase and run it only if X=yes). 
I don't want to do any logic within the parent Multijob (no SCM checkout 
etc or any inline script). I am able to modify the parameter within phase a 
but it does'nt seem to set the parent parameter value. Or in other words, 
when b starts, it still sees the parameter as set by the parent multijob 
and not as changed by a.

I am using the following groovy script within multjob phase a.

def parameters = new ArrayList<StringParameterValue>()
addParameter(parameters, 'X', 'no' )
addNewParamsToBuild(parameters)

private boolean addParameter(ArrayList<StringParameterValue> pl, String 
key, value) {
    pl.add(new StringParameterValue(key, value))
}

private void addNewParamsToBuild(ArrayList<StringParameterValue> 
parameters) {
    def newParams
    def oldParams = build.getAction(ParametersAction.class)

    if (oldParams != null) {
        newParams = oldParams.createUpdated(parameters)
        build.actions.remove(oldParams)
    } else {
        newParams = new ParametersAction(parameters)
    }

    build.addAction(newParams)
}

I also tried this https://themettlemonkey.wordpress.com/tag/jenkins/ in 
multijob phase a but it seems to only set it within a and not the parent 
value so that b can have it.

I am open to use environment varilables too so if there is any way of 
'multijob phase a' setting or changing the global environment varilable 
that 'multijob phase b' can see then that should do too. 

Any help in the direction would really be appreciated.

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/03f71b7e-6907-46ae-b49f-aaf0fb8d0b65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to