Building ASP .NET 5 Applications on Linux with TFS 2015, Part 2: Configuring the build agent

Posted by Daniel Mann - August 14, 2015

header-picture

In my last post, I explained how to configure your TFS server and agent pools to support Linux build agents.

In this post, I'll be setting up a Linux machine to act as a build agent for an on-premise instance of TFS 2015. The TFS 2015 cross-platform build agent is just a Node JS application, so we have some prerequisites to take care of first.

    • First, get a Linux machine! I used an Azure VM running Ubuntu 14.04 LTS, so these steps should work against a similar setup.
    • Connect to your Linux machine via SSH and log in. If you need an SSH client, PuTTY is awesome and it's all I ever use.
    • Install NPM, the Node Package Manager. We'll be using NPM to install the cross-platform build agent. The following command should take care of it:
      sudo apt-get install npmAnswer "yes" to any prompts that come up.
    • Now, for whatever reason, a lot of the upcoming steps depend on the command "node" being available. But NodeJS installs as "nodejs". So we have to add an alias for "nodejs" to "node":
      sudo ln -s /usr/bin/nodejs /usr/bin/node
    • Now run the following command to check your version numbers:
      npm -v && node -v

You should see output like this:

1.3.10
v0.10.25

This means that you have version 1.3.10 of NPM and 0.10.25 of NodeJS installed. Perfect!

  • Now we need to install the cross-platform build agent, which is available on NPM.
    sudo npm install vsoagent-installer -gThat will download the build agent installer. Now make a directory called "build" and switch into that directory, and run the installer:
    mkdir build
    cd build
    vsoagent-installer

    You should see some text like this:

    Installing agent to /home/ictfs-admin/build
    Copying: /usr/local/lib/node_modules/vsoagent-installer/agent /home/ictfs-admin/build
    Copying: /usr/local/lib/node_modules/vsoagent-installer/node_modules /home/ictfs-admin/build
    making scripts executable
    Done.
  • This step is only if you are using an app tier server name that is not using a FQDN
    For example, my server is "ic-tfs-at-01". It's not "ic-tfs-at-01.incyclesoftware.com", or "ic-tfs-at-01.local", or anything like that. That "." matters to the cross-platform agent at the moment; it will not allow you to configure the agent unless there's a "." in there. I submitted a bug fix for this, but it hasn't been merged in yet, so you'll have to do this in the interim. :)My solution is basically to remove the check from the configuration.

    Edit "~/build/agent/configuration.js". I use Nano for this, because I'm not old-school enough to understand how to use vi or Emacs.

    sudo nano ~/build/agent/configuration.js

    Find line 153, it should look like this:

    Configurator.prototype.validate = function (settings) {
    throwIf(!check.isURL(settings.serverUrl), settings.serverUrl + ' is not a valid URL');
    };

    Remove that "throwIf" line and save the file. By the time you read this, they may have merged my fix in. If so, proceed!

  • Now we can run the configuration process.
    node agent/vsoagentIt's going to prompt us for some setup information:
    - User name - enter your build service account. If you're using a domain, Specify it as USER@DOMAIN, not DOMAIN\USER. For example, my domain is "azure", and my user is "tfs-build". So I'm going to enter tfs-build@azure here.
    - Password. No explanation necessary.
    - TFS server URL. So, http://yourServerName:8080/tfs
    - Agent name. Enter whatever you want, I leave it default.
    - Agent pool name. If you made a separate agent pool (I made one called 'linux', enter it here.

    It should look something like this:

    Enter alternate username > tfs-build@azure
    Enter alternate password >
    Enter server url > http://ic-tfs-at-01:8080/tfs
    Enter agent name (enter sets IC-TFS-BA-03Lin) >
    Enter agent pool name (enter sets default) > linux
    successful connect as undefined
    Retrieved agent pool: linux (2)
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_SESSION_ID=1
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SHELL=/bin/bash
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CLIENT=67.85.54.145 4186 22
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_TTY=/dev/pts/0
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap USER=ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap MAIL=/var/mail/ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap PWD=/home/ictfs-admin/build
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LANG=en_US.UTF-8
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap HOME=/home/ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LOGNAME=ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CONNECTION=67.85.54.145 4186 10.0.2.14 22
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LESSOPEN=| /usr/bin/lesspipe %s
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_RUNTIME_DIR=/run/user/1000
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LESSCLOSE=/usr/bin/lesspipe %s %s
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap _=/usr/bin/node
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap OLDPWD=/home/ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap ant not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap clang not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap cmake not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap curl=/usr/bin/curl
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap git not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap jake=.
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap java not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap make=/usr/bin/make
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap mdtool not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap mdtool not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap mvn not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap node.js=/usr/bin/node
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap node.js=/usr/bin/nodejs
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap npm=/usr/bin/npm
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap gulp not found
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap python=/usr/bin/python
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap python3=/usr/bin/python3
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap sh=/bin/sh
    IC-TFS-BA-03Lin
    Creating work folder ...
    Creating env file ...
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_SESSION_ID=1
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SHELL=/bin/bash
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CLIENT=67.85.54.145 4186 22
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_TTY=/dev/pts/0
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap USER=ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap MAIL=/var/mail/ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap PWD=/home/ictfs-admin/build
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LANG=en_US.UTF-8
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap HOME=/home/ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LOGNAME=ictfs-admin
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CONNECTION=67.85.54.145 4186 10.0.2.14 22
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LESSOPEN=| /usr/bin/lesspipe %s
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_RUNTIME_DIR=/run/user/1000
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap LESSCLOSE=/usr/bin/lesspipe %s %s
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap _=/usr/bin/node
    Thu Aug 13 2015 14:55:33 GMT+0000 (UTC) : cap OLDPWD=/home/ictfs-admin
    Saving configuration ...
    2015-08-13T14:55:33.451Z: Agent Started.

    To quit the agent, just press Ctrl-C. You can always re-start it by running node agent/vsoagent again.

Topics: Blog


Recent Posts

InCycle Recognized Across Americas

read more

InCycle, Microsoft & Cowboys

read more

InCycle Named Azure Data Explorer (ADX) Partner

read more