-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Windows
Unable to execute a powershell script from a freestyle job with a custom powershell release defined in Manage Jenkins -> Tools -> PowerShell installations.
I have defined a custom Powershell release like this:
The issues are as follow:
1. As you can see on the above screenshot, the "Path" field is hidden as soon as you check "Install automatically".
2. The following exception occurs in the freestyle job:
00:00:00[Clean Workspaces each 2 hours - Powershell] $ D:\ws\tools\hudson.plugins.powershell.PowerShellInstallation\DefaultWindows -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\Users\SVC-JE~1\AppData\Local\Temp\jenkins18378235241689233705.ps100:00:00Access is denied00:00:00FATAL: command execution failed
Here we see the executable name is missing from the command line.
3. Going back to the tools configuration screen, you can set the path like this:
- delete the existing Powershell installation configuration
- create a new Powershell installation configuration
- enter the path BEFORE clicking on the "Install automatically" checkbox
- check the "Install automatically" checkbox and complete the form.
BUT: if you enter "pwsh.exe" as path, your freestyle job will still fail with:
00:00:05[Clean Workspaces each 2 hours - Powershell] $ D:\ws\tools\pwsh.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\Users\SVC-JE~1\AppData\Local\Temp\jenkins7728088052151415840.ps1
Here the path takes the custom tools' folder path, and that's all. The plugins' subdirectory is missing.
As a workaround, you can update the path with:
hudson.plugins.powershell.PowerShellInstallation\DefaultWindows\pwsh.exe
In that case, your script will be executed, but the plugin cannot update the Powershell installation:
00:00:00Anonymously downloading https://github.com/PowerShell/PowerShell/releases/download/v7.5.2/PowerShell-7.5.2-win-x64.zip into D:\ws\tools\hudson.plugins.powershell.PowerShellInstallation\DefaultWindows\pwsh.exe on Slave1 (w1164-de-pipe1.here.ch) because existing contents is out of date.
00:00:02ERROR: Failed to download https://github.com/PowerShell/PowerShell/releases/download/v7.5.2/PowerShell-7.5.2-win-x64.zip from agent; will try from master instead
00:00:02java.nio.file.NoSuchFileException: D:\ws\tools\hudson.plugins.powershell.PowerShellInstallation\DefaultWindows\pwsh.exe\cs
00:00:02 at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
00:00:02 at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
00:00:02 at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
00:00:02 at java.base/sun.nio.fs.WindowsFileSystemProvider.createDirectory(WindowsFileSystemProvider.java:527)
00:00:02 at java.base/java.nio.file.Files.createDirectory(Files.java:699)
00:00:02 at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
00:00:02 at java.base/java.nio.file.Files.createDirectories(Files.java:793)
00:00:02 at hudson.FilePath.mkdirs(FilePath.java:3731)
00:00:02 at hudson.FilePath.unzip(FilePath.java:712)
00:00:02 at hudson.FilePath.unzip(FilePath.java:688)
00:00:02 at hudson.FilePath$UnzipFrom.invoke(FilePath.java:676)
00:00:02 at hudson.FilePath$UnzipFrom.invoke(FilePath.java:667)
00:00:02 at hudson.FilePath.act(FilePath.java:1213)
00:00:02 at hudson.FilePath.act(FilePath.java:1196)
00:00:02 at hudson.FilePath.unzipFrom(FilePath.java:664)
00:00:02 at io.jenkins.plugins.extratoolinstallers.installers.AuthenticatedDownloadCallable.doDownload(AuthenticatedDownloadCallable.java:281)