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 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.