-
Bug
-
Resolution: Unresolved
-
Minor
-
Jenkins 2.32.2, Windows 7 Pro. Chrome 56
My PowerShell script was in the directory "C:\Program Files (x86)\Jenkins\scripts\MyScript.ps1" but was not being executed. When I removed the double-quotes an exception was thrown:
{{The term 'C:\Program' is not recognized as the name of a cmdlet, function, scri
pt file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At C:\Windows\TEMP\hudson8395162481558588519.ps1:1 char:11
+ C:\Program <<<< Files (x86)\Jenkins\scripts\MyScript.ps1
+ CategoryInfo : ObjectNotFound: (C:\Program:String) [], CommandN
otFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
}}
When I moved the script to a path without spaces D:\Jenkins\scripts it worked fine (without double-quotes).
A brief investigation makes me think it's the Jenkins FileInfo.getRemote method returning the script path in full if it's surrounded in quotes but then the CommandInterpreter.buildCommandLine override is then enclosing the same path in single quotes when creating the array.
The result is a path of '"C:\Program Files (x86)\Jenkins\scripts\MyScript.ps1"' being created. When the quotes are removed in the configuration getRemote just returns C:\Program which becomes 'C:\Program'.