Hello,
We recently found an issue concerning repeaters and dynamic variable. In some cases the dynmaic variable update is not taken by the repeater below.
Steps to reproduce
- Create a configuration
- Add a variable repeatedValues containing "val1,val2"
- Add a step that update the variable with the script below
groovy:
def values = vars.get("repeatedValues").asList();
if(!values.contains("val3")) {
logger.info("Add default value val3");
values.add("val3");
}
if(!values.contains("val4")) {
logger.info("Add default value val4");
values.add("val4");
}
vars.get("repeatedValues").setValue(values.join(","));
build.flushVariables()
I don't know if build.flushVariables() is necessary, but as we have strange comportment I keep it.
-
Add another step called "== Loop" that is repeated using ${vars.getValue("repeatedValues")}
-
Add a step into "== Loop" that juste log the current parameter
-
Execute the configuration and observe that the loop is only repeated twice (val1 and val2).
-
Go into the build overview > Variable and see that the repeatedValues variable contain the expected values (val1,val2,val3,val4)
Workaround
We don't understand if there is a underlying reason to not get dynamically the variable update into the repeater but we found a workaround.
To have the expected repetition:
- encapsulate the repeated "== Loop" into a Sequentil composition step "== Loop root"
- Execute the configuration
- We have the four repetition as expected into the "== Loop root"
Is that issue is identified?
Do we really need to call build.flushVariables()?
Is there a cleaner way to workaround that issue?
Have you an explanation to avoid that kind of comportment?
Regards,
Rafael