管道作业完成时,Azure DevOps 交互式环境代理启动的进程结束

问题描述 投票:0回答:1

我想使用 Azure DevOps 管道将长时间运行的 C# 可执行文件部署到 Windows Server 2019 计算机。可执行文件需要运行提升的 并调用无法在会话 0 中运行的外部应用程序。因此,可执行文件需要在 UI 会话本身中运行。因此我使用交互式代理。不幸的是,每当管道作业完成时,可执行文件总是关闭,但我需要它继续运行。

可以使用以下管道重现该行为。

jobs: - deployment: environment: MyEnvironment.MyInteractiveAgent strategy: runOnce: deploy: steps: - powershell: Start-Process -Verb RunAs C:\Windows\notepad.exe
当我自己以管道用户身份在目标计算机上从 PowerShell 窗口执行 

Start-Process -Verb RunAs C:\Windows\notepad.exe

 时,我可以关闭 PowerShell 窗口,记事本保持打开状态。

无论我还是管道代理启动记事本,它似乎都是PowerShell的子进程,根据以下脚本启动它(需要PowerShell Core)。

$process = Get-Process notepad; while ($process) { Write-Host "$($process.Id) - $($process.Name)"; $process = $process.Parent; } # Starting myself Starting from agent # ------------------------------------------- # 9812 - notepad 3940 - notepad # 3480 - powershell 1676 - powershell # 5004 - explorer 11388 - powershell # 1720 - Agent.Worker # 15748 - Agent.Listener # 14708 - cmd
    
windows powershell azure-devops azure-pipelines elevated-privileges
1个回答
0
投票
原因是交互代理不小心跑高了。当我以非提升方式重新启动它时,可执行文件在管道作业完成后继续运行。

要检查进程是否以提升的速度运行,我可以使用任务管理器的

Elevated

列或
此 PowerShell 脚本

我不明白为什么药剂升高会有这种副作用,但我的问题现在已经解决了。

© www.soinside.com 2019 - 2024. All rights reserved.