VSTS has a few readily available build agents that are hosted and shared with other users on the platform. If you have special build dependencies, don’t like waiting for others on shared hosts, want faster builds, or just simply want to own the agent, then the following short article should give you just enough to get up and running quickly.
Start by navigating into VSTS and create a Personal Access Token (PAT). To get to the PAT provision screen, click on your face in the upper right navigation and click security in the drop down nav. It took me a minute or two to find this menu so here’s an image for quick reference.
Next click on Add new Personal Access Token. On the following screen provide a description/name “VSTS Build Agent” or whatever you want and set a selected scope of Agent Pools (Read, Manage). After you click Create Token, the token string will be revealed on the next page. Copy the token and drop it in the docker run command below. For the VSTS_ACCOUNT, it’s simply the name that appears before your .visualstudio.com address in the URL.
docker run \ -e VSTS_ACCOUNT=nameofvsts \ -e VSTS_TOKEN=xxxxxxxxaaabbbbbbbb \ --name vstsbuildagent \ -v /var/run/docker.sock:/var/run/docker.sock \ -it -d microsoft/vsts-agent
The following docker run will take a few minutes to download all of the packages and build tools, including the following:
- Basic command-line utilities (curl, ftp, etc.)
- Essential build tools (gcc, make, etc.)
- Azure CLI 2.0.28
- CMake 3.10.2
- Go 1.9.4 and 1.10
- HipHop VM 3.24.3
- OpenJDK 7 (1.7.0_95), 8 (1.8.0_151), and 9 (internal)
- Java tools (Ant 1.9.6, Gradle 4.6, Maven 3.3.9)
- MySQL Client 14.14
- .NET Core SDK 2.1.4
- Node.js 8.10.0 LTS
- Powershell Core v6.0.1
- Python 2.7.12 and 3.5.2
- Scala sbt-extras
- Subversion 1.9.3
For reference, check out the latest standard image docs on github for version references.
When the container actually spins up it will automatically connect to VSTS. To confirm, go to VSTS settings > Agent Queues and open the Default queue. You should see there is an agent online with a random id number. If you click the tab for agent capabilities, you should see a table that lists all the agent’s build tools and frameworks along with their corresponding version numbers.
The last step is to actually invoke a build on any of the VSTS Projects you have setup to use a build pipeline. Do a quick davidemanske.com blog search to find other VSTS and build pipeline articles.
Photo by Samuel Zeller on Unsplash