无法通过确认:$ false to vmware powercli来自Groovy

发布于 2025-02-05 02:44:31 字数 406 浏览 3 评论 0原文

我必须在Jenkins管道中使用PowerCli停止VM。 所必需的以下错误

def stopVM(String vmName) {
        powershell (returnStdout: true, script: """ Stop-VM \"${vmName}\"  -Confirm:$false """)
    }

通过 -confirm:$ false 在管道中 :

I have to stop the vm using PowerCLI in jenkins pipeline. getting below error while passing -Confirm:$false which is required to handle confirmation dialog

def stopVM(String vmName) {
        powershell (returnStdout: true, script: """ Stop-VM \"${vmName}\"  -Confirm:$false """)
    }

Error in Pipeline: 'org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

智商已欠费 2025-02-12 02:44:33

我今天在同样的问题上挣扎。逃避导致$符号消失,因此它不是解决方案。也使用Tripple单引号,因为我必须传递param(作为问题的所有者-VM名称),因此只有可能是连接不同类型的书面字符串。
它应该是类似的:

 """Stop-VM "${vmName}" """ + '-Confirm:$false' 

我对该解决方案不满意,但它正在起作用(而且我找不到其他解决方案)

I was struggling with same problem today. Escaping caused $ sign to disappear so it is not a solution. Using tripple single quotes also since I have to pass param (as owner of question - vm name) so only possibility is to join different types of written string.
It should be something like:

 """Stop-VM "${vmName}" """ + '-Confirm:$false' 

I'm not glad of that solution but it is working (and I didn't find any other solution)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文