How to pass a String parameter with spaces in Jenkins to environment variable
If the input string is failing due to folders with spaces not having quotes around them, try adding quotes around every object.
The InpFolderList already adds end quotes:
InpFoldersList=&quot;\&quot;$inpFoldersList&quot;\&quot;
Add the quotes around every object.
groovy:
class Example { 
   static void main(String[] args) { 
        String FolderList = &quot;test1,test2,test3,Folder name1,Folder name2,Folder name3&quot;;
        println(FolderList.replaceAll(&quot;,&quot;,&quot;\&quot;,\&quot;&quot;));
   } 
}

Output: (End quotes are left off)
test1&quot;,&quot;test2&quot;,&quot;test3&quot;,&quot;Folder name1&quot;,&quot;Folder name2&quot;,&quot;Folder name3
Test Code: https://www.jdoodle.com/execute-groovy-online/ (Copy / Paste Code and Execute)
Using above as an example, you could also add the end quotes and have a complete String variable to pass as $InpFoldersList, which would remove confusion if attempting to debug.
Reference: http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/StringGroovyMethods.html#replaceAll(java.lang.CharSequence,java.util.regex.Pattern,java.lang.CharSequence)