Reputation: 5894
I have a Jenkins server running v2.107.3, and a Windows agent node. A simple test powershell pipeline is failing because it can't find "powershell".
Here's my test pipeline:
pipeline {
stages {
stage('test') {
steps {
powershell(script:'Write-Output Hello')
}
}
}
}
And the response from the agent is always:
C:\Jenkins\workspace\test_ps_remoting@tmp\durable-ccca47a5\powershellWrapper.ps1 : The term 'powershell' is not recognized as the name of a cmdlet, function, script 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:\Jenkins\workspace\test_ps_remoting@tmp\durable-ccca47a5\powershellHelper.ps1:54 char:9
+ & { & $MainScript | Out-FileNoBom -Writer $OutputWriter } *>&1 | ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (powershell:String) [powershellWrapper.ps1], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,powershellWrapper.ps1
I've managed to grab a copy of the files in @tmp as they run, and if I execute the steps manually, it seems to work just fine:
. .\powershellHelper.ps1
Execute-AndWriteOutput -MainScript .\powershellWrapper.ps1 -OutputFile out.txt -LogFile log.txt -ResultFile result.txt
Creates the files expected, with the "result" of 0
and the log of Hello
.
Upvotes: 3
Views: 5448
Reputation: 19704
Based on your error, the process likely can't find the powershell executable, meaning it's
If you fix either of these, your problem should be resolved.
Upvotes: 2