简体   繁体   中英

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

I have setup Release definition with 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.

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. 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

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. 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:

在此处输入图片说明

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:

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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