I have two groovy scipts (executed in Jenkins pipeline), one with variables:
// Params file
PARAM1 = "1"
PARAM2 = "2"
PARAM3 = "3"
PARAM4 = "4"
return this
and the second one that loads this file and uses the params:
def load_params() {
def parameters = load "params.groovy"
final_parameter = ""
for (parameter in parameters) {
if(final_parameter == "") {
final_parameter = parameter.key.toUpperCase() + "=" + parameter.value
} else {
final_parameter = final_parameter+ "&|&" + parameter.key.toUpperCase() + "=" + parameter.value
}
}
return final_parameter
}
return this
Issue is that doing the iteration over parameters is not working. The type is not a map so I cannot access variables like that.
I would use parameters.PARAM1 to handle it, but the first script is dynamic and names change so there is a need to do it without hard defining the name.
Is there any way to change/iterate the parameters to get the "key" and "values"?