简体   繁体   English

在Jenkins PowerShell构建步骤中调用的PowerShell脚本无限期挂起

[英]PowerShell script called from within the Jenkins PowerShell build step hangs indefinitely

I have a Jenkins (1.493) project that uses the Jenkins PowerShell build step to execute a PowerShell script. 我有一个Jenkins(1.493)项目,该项目使用Jenkins PowerShell构建步骤来执行PowerShell脚本。 Inside that script I want to invoke another script that is stored inside a file. 在该脚本中,我想调用存储在文件中的另一个脚本。 I have now reduced it to the following: 我现在将其简化为以下内容:

Script inside Jenkins PowerShell build step: Jenkins PowerShell构建步骤中的脚本:
& "\\\\stemmer.local\\sidevelopment\\cvdev\\devbase\\jenkins\\PowerShell\\Test.ps1"

Content of Test.ps1: Test.ps1的内容:
write-host 'Hello world!'

Whenever this Jenkins project executes, the PowerShell build step hangs indefinitely. 每当执行此Jenkins项目时,PowerShell构建步骤都会无限期挂起。

Things I have tried/verified so far: 到目前为止,我尝试过/验证过的事情:

  • Adding some output before the invocation of Test.ps1 shows me that the Jenkins PowerShell script is being execute normally up to the point where Test.ps1 is called. 的调用之前添加一些输出Test.ps1显示我的詹金斯PowerShell脚本正在正常执行到哪里点Test.ps1被调用。
  • The file Test.ps1 exists and is reachable from the build slave that executes the script. 文件Test.ps1存在,并且可以从执行脚本的生成从服务器访问。 If I alter the file's name, I get the expected error message from PowerShell... 如果更改文件名,则会从PowerShell中收到预期的错误消息...
  • Exchanging the " for ' in the 1st script does not change anything. Also, using dot-sourcing rather than & does not help. 在第一个脚本中将“替换为”不会改变任何内容。此外,使用点源而不是&也无济于事。
  • The file Test.ps1 can be executed properly from the powershell itself using the same command line that is being used in the Jenkins PowerShell script. 可以使用Jenkins PowerShell脚本中使用的相同命令行从powershell本身正确执行文件Test.ps1
  • The execution policy for PowerShell has been set to unrestricted on my development host as well as on the Jenkins build slave. 在我的开发主机以及Jenkins构建从属服务器上,PowerShell的执行策略已设置为unrestricted
  • I've tried replacing the PowerShell build step with a Windows batch command build step that looks like this: 我尝试用如下所示的Windows批处理命令构建步骤替换PowerShell构建步骤:
    powershell.exe -InputFormat None -File "\\\\stemmer.local\\sidevelopment\\cvdev\\devbase\\jenkins\\PowerShell\\Test.ps1"
    and played around a little with the parameters of powershell.exe, but the results were - in those cases that were syntactically and otherwise correct as far as I can tell - always the same. 并使用powershell.exe的参数进行了一些调整,但是结果-在语法上,就我所知正确的情况下-始终相同。

I only found few references to problems that sounded similar, but none of the approaches mentioned elsewhere did help me fix this. 我只发现很少有人听起来相似的问题,但是其他地方提到的方法都没有帮助我解决此问题。 I am absolutely puzzled, and wondering whether someone encountered this issue before (and maybe even got a scenario like the one I have in mind running). 我完全感到困惑,想知道是否有人之前遇到过此问题(甚至可能遇到了我想到的那种情况)。

Thanks a lot for any input! 非常感谢您的任何投入!

Volker

have you tried to set execution policy to bypass ? 您是否尝试将执行策略设置为绕过?

Copy the script file locally, then invoke it from within the Jenkins PowerShell plugin - that way it works as expected. 将脚本文件复制到本地,然后在Jenkins PowerShell插件中调用它-这样可以按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM