gpt4 book ai didi

powershell - 为什么我不能让 Jenkins Powershell 插件工作?

转载 作者:行者123 更新时间:2023-12-04 17:20:50 24 4
gpt4 key购买 nike

为什么我不能让 Jenkins“Powershell 插件”工作?

我可以使用“执行 Windows 批处理命令”构建步骤在 Jenkins 上运行一个 powershell 脚本,命令如下:

powershell -ExecutionPolicy ByPass -File script.ps1

但是我无法使用“Windows Powershell”构建步骤和此命令使用Jenkins“Powershell插件”运行powershell脚本,因为Windows执行策略未设置错误不允许它运行:
script.ps1

有谁知道为 Jenkins 提供“Powershell 插件”以成功运行脚本的正确参数?否则,我将只使用批处理脚本解决方法。

最佳答案

正确的做法是在你的机器上设置一个执行策略(一次性操作),此时你不需要每次都绕过它,Jenkins 插件应该“正常工作”。你不能吗?

一个合理的起始设置是 RemoteSigned,它允许你很好地执行本地脚本,但仍然不允许从 Internet 下载脚本。

在提升的 PowerShell 提示符下,您将运行:

Set-ExecutionPolicy RemoteSigned

另见: http://technet.microsoft.com/library/hh849812.aspx

更新:摘自关于应用政策及其行为方式的帮助:

If you set the execution policy for the local computer (the default) or the current user, the change is saved in the registry and remains effective until you change it again.



当然,如果您的机器在域中,那么组策略可以恢复它。

关于powershell - 为什么我不能让 Jenkins Powershell 插件工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18138193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com