Hi,
I'm using the remote file loader to load pipeline scripts from GIT. Each script represents a different test scenario i need deploy and test. A given remote file looks like this:
def x, y, z
def initialize() {
set x
set y
set z
}
def setupEnv() {
get y to do something
}
def runTests() {
get x and z to do something
}
return this;
All my test scenario classes use the same variables x, y and z but the methods perform different things. My problem is that when i load a script from git all the variables (x, y, z) become visible everywhere. So, if i want to run 2 test scenarios in parallel and load both scripts from git the variables are messed up (they overwrite each other).
def env1, env2
fileLoader.withGit('https://github.com/jenkinsci/workflow-remote-loader-plugin.git', 'master', null, '') {
env1= fileLoader.load('examples/fileLoader/helloworld');
env2 = fileLoader.load('examples/fileLoader/environment');
}
parallel 'env1': {
env1.initialize()
env1.setupEnv()
}, 'env2': {
env2.initialize()
env2.setupEnv()
}
So when i run the above the variables x,y,z are based on which initialize() method was called last (env1 or env2) so everything is messed up.
How can i resolve this issue? Can i make the variables defined in a script that is loaded via fileLoader visible only to the script itself?
Thanks