简体   繁体   English

Jenkins PowerShell:在 Jenkins 但不在 Z3D265B4E03EEEF0DDF178B181FA 中执行时,使用 Passthru 的启动进程返回不同的进程 ID

[英]Jenkins PowerShell: Start-Process with Passthru returns a different process ID when executed in Jenkins but not on PowerShell

I'm experiencing a weird scenario where I want to open a.rdp file and get its Process ID on a Jenkins Pipeline.我遇到了一个奇怪的场景,我想打开一个 .rdp 文件并在 Jenkins 管道上获取它的进程 ID。

My PowerShell Script (which based from this answer ):我的 PowerShell 脚本(基于此答案):

$app = Start-Process "$env:windir\system32\mstsc.exe" -ArgumentList "C:\Users\AzureUser\Desktop\MyRDP.rdp /h:900 /w:1600" -WindowStyle Minimized -PassThru

Write-Host $app.id

When I ran this on PowerShell it works as expected.当我在 PowerShell 上运行它时,它按预期工作。 However, when I tried to execute this script on a Jenkins Pipeline, it opens the.rdp file but returns a different process ID.但是,当我尝试在 Jenkins 管道上执行此脚本时,它会打开 .rdp 文件但返回不同的进程 ID。

Here's the screenshot of the result.这是结果的屏幕截图

I also tried enclosing it in an Invoke-Command to make sure that it runs on a 64-bit Powershell but it did not change a thing.我还尝试将它包含在Invoke-Command中,以确保它在 64 位 Powershell 上运行,但它没有改变任何东西。

I'm wondering what might be the other possible cause of this.我想知道这可能是其他可能的原因。 Any help is going to be appreciated.任何帮助将不胜感激。 :) :)

The solution is just simple.解决方案很简单。 I will post my answer anyway incase anyone might encounter the same problem I have.无论如何,我都会发布我的答案,以防有人遇到与我相同的问题。 You just need to make sure that Jenkins runs on 64-bit.您只需要确保 Jenkins 在 64 位上运行。 That's all and worked like a charm.这就是全部,就像一个魅力。

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

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