由于未找到powershell"

时间:2018-05-30 11:43:49

标签: powershell jenkins jenkins-plugins jenkins-pipeline

我有一台运行v2.107.3的Jenkins服务器和一个Windows代理节点。一个简单的测试PowerShell管道失败了,因为它无法找到" powershell"。

这是我的测试渠道:

pipeline {
    stages {
        stage('test') {
            steps {
                powershell(script:'Write-Output Hello')
            }
        }
    }
}

代理商的回应总是:

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

我设法在运行时抓取@tmp中的文件副本,如果我手动执行这些步骤,它似乎工作得很好:

. .\powershellHelper.ps1
Execute-AndWriteOutput -MainScript .\powershellWrapper.ps1 -OutputFile out.txt -LogFile log.txt -ResultFile result.txt

使用"结果"创建预期的文件。 0的日期和Hello的日志。

1 个答案:

答案 0 :(得分:1)

根据您的错误,该过程可能找不到powershell可执行文件,这意味着它是

  1. 未完全修补
  2. 不在PATH环境变量中
  3. 如果您修复了其中任何一项,则应解决您的问题。