TFS 2015 Build system – Build Agents

26. July 2016 - Kine
This post was originally published on this site

Agents of TFS 2015

In previous part we were I was describing the TFS 2015 build system and how to create your first build template. Today, I will describe how to prepare environment, where the build will be done.

Build environment

To run the own build process you need some PC, where you have all needed to do the build. You can choose to use some VPC, your workstation or another server, it does not matter. What you need for the build:

In case of NAV, you cannot use the Build agents available as part of the Team Services, because you need to install NAV on the machine. Thus it must be your own PC/VPC, but it does not matter if on prem or somewhere in cloud. It could be used together with Team Services.

I think that I do not need to describe how to create clean VPC with all the prerequisities, except the VSO Agent.

VSO Agent

When all is prepared and you need to install the VSO Agent on your build server, all you need is to open your TFS web portal and navigate into the Administration of your server, Agent pools tab, and select Download agent.

Download the agent, expand in somewhere and run the ConfigureAgent.cmd as admin. There you need to put few values to correctly configure the agent:

After you answer all questions, the agent is configured and started. Next time you can run the agent by starting RunAgent.cmd. Do not forget to run the agent as admin, else you will not have needed access e.g. when creating new NAV server instance etc.
The VSO Agent is not searching for PowerShell modules in the standard PSModulePath! If you need to use your own PowerShell modules, you can put them into AgentWorkerModules subfolder, or load them including full module path or in another way. This could make you headache, if you forgot about this. Another problem connected with this is, that the subfolder is cleaned up when the Agent is updated. You can update all your agents from the TFS Admin portal.
After you have at least one Agent up and running, you can queue your first TFS 2015 Build.

Agent Capabilities

In the Control panel, where you have downloaded the agent, you should now see the agent in the list. From there, you can configure it – enable/disable the agent, update the agents (context menu on the pool), enable autoprovisioning of the agents (don’t ask me now what it is doing) and you can setup the capabilities of the agents. You can use the the capabilities to create “Name-Value” pairs, which than could be used for choosing correct agent to build the specific Build Definition (See the General tab section in previous part). The build will be running on  agent, which have needed capabilities defined as specified on the build template. In this way you can e.g. mark Agents for different NAV versions/builds/purposes (test, live, devel …) – you do not need to create separate agent pools for this.
Now you have all needed to run your build. Next time we will look at how to run NAV Tests under TFS 2015.