Automating Build – Pools, Queues and Agents

If you have been following my last few posts, you now are in a position where we are using the tools available to us in Visual Studio to help us improve the quality of our code. We also have the ability to quickly test our code using our unit tests. As our Code Coverage increases, we will have even more confidence in our code, and the confidence to change it and know if we have broken any of it. Our next step is to add some automation to our verification process. To do this, we are going to utilise the VSTS/TFS agents to perform tasks such as build and release for us. If you are using VSTS, then hosted agents are already supplied. You can add your own (as I am doing here) if you want greater control over the agent machine itself, or if you use a lot of build minutes (you get so many free minutes on a hosted agent and then it becomes chargeable).

Using VSTS Build

Rather than using the VSTS hosted agent to build my project, I want to use my own. This is just to give me more flexibility and better visibility as to what happens during the build process. In order to register my agent with my VSTS collection, I performed the following steps:

  • On the machine I am installing the agent on, navigate to your VSTS account, click the administrative cog of power in the top right hand corner. Then select Agent pools.

 

Click “New Pool”, and give your new pool a name. I am calling mine “Home” (as that’s where my agents will be!). Leave auto-provision queue in collection ticked (the only time I can figure you wouldn’t leave this ticked is if you were running multiple team project collections, and not sharing pools between them).

 

Now you have a pool (and a queue – that was created in your team project collection automatically for you), we need to add some agents to that pool so that we can do some work. Click “Download agent” this will download a zip file to your PC. Extract the zip file to where you want to install the agent (I am going to extract mine to C:\Agents\{AgentName}

 

Once this is done, run the “ConfigureAgent” cmd file as administrator. You will be prompted for a few bits of information:

  • Agent Name
  • URL for Team Foundation Server (or VSTS)
  • Which Pool should the agent live in?
  • Wher should the working folder be for the agent?
  • Run as a service?
  • Which user account should the agent run as?

At this point, you will be prompted to enter your VSTS account details. The agent needs this as a once off in order to authenticate against your VSTS account and register itself.

 

Enter your credentials to complete the agent setup.

Your agent will now appear in the web interface:

And that's it - your agent is ready to start performing automated tasks! Our next job is to use the agent to perform our Continuous Integration build, see next post.



Tagged: TFS Build, Automation,
Categorised: Application Lifecycle Management,
By:
On: