詹金斯没有找到 powershell
Jenkins not finding powershell
当我尝试在我的 biuld 中 运行 Windows Powershell 命令时遇到此错误。我不知道如何添加 Powershell.exe 到这个?这是一个插件,我不知道它位于何处或如何使用它。
[DeploymentTest] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& '/tmp/jenkins8870821876113230026.ps1'"
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
。
.
.
Caused: java.io.IOException: Cannot run program "powershell.exe" (in directory "/var/lib/jenkins/workspace/DeploymentTest"): error=2, No such file or directory
您正在 运行 将它放在 Linux box.Please 上,根据需要 Windows 到 运行 切换到 Windows 盒子powershell.
如果您在 Linux 上 运行 dotnet/powershell,请使用 shell 步骤并调用 linux powershell 可执行文件 /usr/bin/pwsh
在里面。这是一个在 dotnet5 debian 容器上为我工作的示例:
stage('PreBuild') {
steps {
sh '''
wget -v https://aka.ms/install-artifacts-credprovider.ps1
/usr/bin/pwsh -File ./install-artifacts-credprovider.ps1 -AddNetfx
dotnet --version
# reset the nuget credentials
dotnet nuget update source "infrastructure"
'''
}
}
当我尝试在我的 biuld 中 运行 Windows Powershell 命令时遇到此错误。我不知道如何添加 Powershell.exe 到这个?这是一个插件,我不知道它位于何处或如何使用它。
[DeploymentTest] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& '/tmp/jenkins8870821876113230026.ps1'"
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
。 . .
Caused: java.io.IOException: Cannot run program "powershell.exe" (in directory "/var/lib/jenkins/workspace/DeploymentTest"): error=2, No such file or directory
您正在 运行 将它放在 Linux box.Please 上,根据需要 Windows 到 运行 切换到 Windows 盒子powershell.
如果您在 Linux 上 运行 dotnet/powershell,请使用 shell 步骤并调用 linux powershell 可执行文件 /usr/bin/pwsh
在里面。这是一个在 dotnet5 debian 容器上为我工作的示例:
stage('PreBuild') {
steps {
sh '''
wget -v https://aka.ms/install-artifacts-credprovider.ps1
/usr/bin/pwsh -File ./install-artifacts-credprovider.ps1 -AddNetfx
dotnet --version
# reset the nuget credentials
dotnet nuget update source "infrastructure"
'''
}
}