简体   繁体   English

如何在单个代理程序池下的所有代理程序上运行Powershell脚本

[英]How to run a powershell script on all agents under single agent pool

I have setup Release definition with Visual Studio Test Version 2. 我在Visual Studio Test Version 2中安装了发行版定义。

I have created an Agent phase and then created visual studio test v2 task for parallel execution of test runs. 我已经创建了一个Agent阶段,然后创建了Visual Studio Test v2任务以并行执行测试运行。

Question: I want to run a power shell script on all Build Agents(Ten Machines) in Agent pool before execution of VISUAL STUDIO TEST V2 TASK in the same Agent phase. 问:我想在同一Agent阶段执行VISUAL STUDIO TEST V2 TASK之前,在Agent池中的所有Build Agent(十台计算机)上运行Power Shell脚本。 Is there any way to do this or an alternative workaround? 有什么方法可以做到这一点或其他解决方法?

Have you tried deployment groups? 您是否尝试过部署组?

I generally need to run some installation scripts on my agent machines time and again and I've realised the best way to go about this is via a deployment group. 我通常需要在代理计算机上一次又一次地运行一些安装脚本,并且我已经意识到实现此目标的最佳方法是通过部署组。 When you configure the machine against an agent pool, also setup a deployment agent against a custom deployment pool. 当根据代理程序池配置计算机时,还应根据自定义部署池设置部署代理程序。 The same machine thus has an agent and a deployment agent process running. 因此,同一台计算机上正在运行一个代理和一个部署代理进程。

Once all machines are listed in the deployment pool all I need to do is create a new release with a deployment group phase, add the script and run the release. 在部署池中列出所有计算机之后,我要做的就是创建一个具有部署组阶段的新版本,添加脚本并运行该版本。 The script is then executed on all the participant machines. 然后在所有参与者计算机上执行该脚本。

在此处输入图片说明

https://docs.microsoft.com/en-us/vsts/pipelines/release/deployment-groups/?view=vsts https://docs.microsoft.com/en-us/vsts/pipelines/release/deployment-groups/?view=vsts

To me, the only way you could do this would be to create an agent phase for each agents you need to run your script on and set the demands with Agent.Name equals yourAgentName. 对我来说,唯一可行的方法是为每个需要运行脚本的代理创建一个代理阶段,并使用Agent.Name等于yourAgentName设置需求。 That would allow you to make sure all agents are targeted. 这将使您确保所有代理商都已成为目标。

If you only want to run PowerShell task before VS Test task for each agent machine separately , you can add the two tasks in same agent phase , and set the agent phase as: 如果只想为每个代理计算机分别在VS Test任务之前运行PowerShell任务 ,则可以在同一代理阶段添加这两个任务,并将代理阶段设置为:

在此处输入图片说明

Then the tasks execute order as: 然后任务执行顺序如下:

agent 1 - PowerShell task
agent 1 - VS Test task
agent 2 - PowerShell task
agent 2 - VS Test task
...
agent 10 - PowerShell task
agent 10 - VS Test task

If you want to execute the PowerShell task on each agent machine firstly and then execute VS Test task on each agent machine , you should add the two tasks in two agent phases , and set both agent phases as: 如果要先在每台代理计算机上执行PowerShell任务,然后在每台代理计算机上执行VS Test任务 ,则应在两个代理阶段中添加这两个任务,并将这两个代理阶段设置为:

在此处输入图片说明

Then the task execute order as: 然后任务执行顺序为:

agent 1 - PowerShell task
agent 2 - PowerShell task
...
agent 10 - PowerShell task
agent 1 - VS Test task
agent 2 - VS Test task
...
agent 10 - VS Test task

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

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