tfsazure-devopscontinuous-integrationbuild-agent

How to trigger one task present in Release Definition on multiple servers in Agent Phase?


I am using TFS 2017 update 3, In TFS 2017, I have a Release Definition in which i have a command line task thorugh which I call the cli of an automation application by passing it an arguments like below

"C:\Program Files (x86)\Auto-2019-Q1\Auto-Cli" -scriptName "Driver_Smoke.xlsx" -scriptLocation "C:\Next_Gen"

and it does run the application successfully but now i have to run the same task on multiple servers where i have already configured build agents so that the automation can be executed on multiple servers at the same time.

For this, I have added an agent phase in the release definition and have added the agent name in the demands but it works only on one server and doesn't works simultaneously on the other server.

However, I can add another agent phase option and then give the agent name of another server but then i'll have to wait for the previous agent phase task to be completed. This would take a lot of time.

I tried giving two agent.name in demands but it doesn't work like that. so, is it possible to run a task on multiple servers at the same time in release definition?


Solution

  • I have found one workaround for this using the existing tasks in TFS Release definition. What I did is,

    1. I have configured two deployment agent on each server.
    2. Copied the above mentioned cli commands into the notepad and created a batch file of it.
    3. Created a Task in task scheduler to execute the batch file whenever the build agent service is started.
    4. In the Release definition, once the deployment of the package is done and after which we need to run the automation using the tool, I added a Run on agent task in RD and associated one of the build agent name where i needed to run the automation tool and under the Run on agent task I added 3 tasks i.e. one to start the service and two task to stop the service, you can repeat the same set of task for multiple servers where you need to run the automation tool thorugh CI.
    5. So, here when the deployment is done the Run on Agent task gets started and it first stops the service and then it start the service due to which the task created in tasks scheduler get triggered and the tool gets executed and then you can stop the service as you no longer need the service to run. By using this process, i no longer need to wait for a long time except couple of seconds in order to run the automation tool on multiple servers simultaneously. enter image description here