简体   繁体   English

有没有办法用 Azure-Pipelines 打开多个 CMD 实例?

[英]Is there a way to open multiple instances of CMD's with Azure-Pipelines?

I'm using Azure-Pipelines for my CI.我将 Azure-Pipelines 用于我的 CI。 In my pipeline, I need to use multiple instances of a CMD (Windows).在我的管道中,我需要使用 CMD (Windows) 的多个实例。 For example, one CMD needs to start and continuously run a server, while the other needs to then deploy an app while the server is still running.例如,一个 CMD 需要启动并持续运行服务器,而另一个需要在服务器仍在运行时部署应用程序。

When using the CMD task, it only uses one instance of the CMD, so when I run the server, it never finishes and never gets to running the app.当使用 CMD 任务时,它只使用 CMD 的一个实例,所以当我运行服务器时,它永远不会完成,也永远不会运行应用程序。

Is there a way to run multiple instances of a CMD with Azure-Pipelines?有没有办法用 Azure-Pipelines 运行 CMD 的多个实例?

You can start cmd.exe on the agent machine from a powershell task using Start-Process command.您可以使用Start-Process命令从 powershell 任务在代理计算机上启动 cmd.exe。

So you can add multiple powershell tasks to start multiple CMD instances on the agent machine.所以可以添加多个 powershell 任务在代理机器上启动多个 CMD 实例。 Or you can start multiple CMD instances in one powershell task.或者,您可以在一个 powershell 任务中启动多个 CMD 实例。 Se below example:以下示例:

steps:
  - powershell: |
    'Start-Process -FilePath "C:\Windows\System32\cmd.exe" -verb runas -ArgumentList {/k echo "hello"}' 
  - powershell: |
    'Start-Process -FilePath "C:\Windows\System32\cmd.exe" -verb runas -ArgumentList {/k echo "world"}'

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

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