Forum Discussion

hb's avatar
hb
Occasional Contributor
6 years ago

use filelist across projects groovy scripts

I have two projects, groovyscriptsLibrary and second project is uploadbinding, there is a step in first project that reads the list of xml files and sets it into the context. 

 

I am calling the step as part of second project. and want to use that filelist 

fileListScript:- project1

def fileList = []
def requestFileLocation = context.expand( '${#Global#RequestFilePath}' )
new File(requestFileLocation).eachFile { f ->
if (f.isFile()&& f.name.endsWith('.xml'))
{
def filename = f.name[0..-1]
fileList.add(filename)
log.info filename
}
}

context.put('fileList',fileList)

 

second script in project2;

def requestFileLocation = context.expand( '${#Global#RequestFilePath}' )
log.info(requestFileLocation)
File file = new File(requestFileLocation +"\\"+ context.get('fileList').last())
context.put('ffile',file)

 

filelist object is coming as null. I have tried to call the filelistscript from project2 as well the object is still null. is there a way i could use this across projects?

1 Reply

  • hb's avatar
    hb
    Occasional Contributor

    I was able to solve this. and had the scripts to work.

     

    thank you