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.
Building ASP .NET 5 Applications on Linux with TFS 2015, Part 2: Configuring the build agent
1. In my last post,I explainedhowtoconfigure yourTFSserverandagentpoolsto supportLinux build
agents.
In thispost,I'll be settingupa Linux machine toact as a buildagentforan on-premise instance of TFS
2015. The TFS 2015 cross-platformbuildagentisjustaNode JSapplication,sowe have some
prerequisitestotake care of first.
First,geta Linux machine!IusedanAzure VMrunningUbuntu14.04 LTS, so these stepsshould
workagainsta similarsetup.
Connectto yourLinux machine viaSSHand log in.If you needanSSH client, PuTTYisawesome
and it'sall I everuse.
Install NPM,the Node Package Manager.We'll be usingNPMto install the cross-platformbuild
agent.The followingcommandshouldtake care of it:
sudoapt-getinstall npmAnswer"yes"toanypromptsthat come up.
Now, forwhateverreason,alotof the upcomingstepsdependonthe command"node"being
available.ButNodeJSinstallsas"nodejs".Sowe have toaddan aliasfor"nodejs"to"node":
sudoln -s/usr/bin/nodejs /usr/bin/node
Nowrun the followingcommandtocheckyour versionnumbers:
npm-v && node -v
You shouldsee outputlike this:
1.3.10
v0.10.25
Thismeansthat youhave version1.3.10 of NPMand 0.10.25 of NodeJSinstalled.Perfect!
Nowwe needtoinstall the cross-platformbuildagent,whichisavailableonNPM.
sudonpm install vsoagent-installer-gThatwill downloadthe buildagentinstaller.Now make adirectory
called"build"andswitchintothatdirectory,andrunthe installer:
mkdirbuild
cd build
vsoagent-installer
You shouldsee some textlike this:
Installingagentto/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
makingscriptsexecutable
Done.
This step is only if you are using an app tier server namethatis notusing a FQDN
For example,myserveris"ic-tfs-at-01".It'snot "ic-tfs-at-01.incyclesoftware.com",or"ic-tfs-at-01.local",
or anythinglike that.That"." mattersto the cross-platformagentatthe moment;itwill notallow youto
configure the agentunlessthere'sa "." inthere.I submittedabugfix forthis,but ithasn't beenmerged
inyet,so you'll have todo thisin the interim.:)Mysolutionisbasicallytoremove the checkfromthe
configuration.
Edit"~/build/agent/configuration.js".Iuse Nanoforthis,because I'mnot old-school enoughto
understandhowtouse vi or Emacs.
sudonano ~/build/agent/configuration.js
Findline 153, it shouldlooklike this:
2. Configurator.prototype.validate =function (settings) {
throwIf(!check.isURL(settings.serverUrl), settings.serverUrl +' isnot a validURL');
};
Remove that"throwIf"line andsave the file.Bythe time youreadthis,theymayhave mergedmyfix in.
If so, proceed!
Nowwe can run the configurationprocess.
node agent/vsoagentIt'sgoingtopromptusfor some setupinformation:
- User name - enteryourbuildservice account.If you're usingadomain, Specify it as USER@DOMAIN,
notDOMAINUSER.Forexample,mydomainis"azure",andmyuseris"tfs-build".SoI'mgoingto enter
tfs-build@azure here.
- Password.Noexplanationnecessary.
- TFS serverURL. So,http://yourServerName:8080/tfs
- Agentname.Enterwhateveryouwant,Ileave itdefault.
- Agentpool name.If youmade a separate agentpool (Imade one called'linux',enterithere.
It shouldlook somethinglike this:
Enter alternate username>tfs-build@azure
Enter alternate password >
Enter serverurl > http://ic-tfs-at-01:8080/tfs
Enter agentname (entersetsIC-TFS-BA-03Lin) >
Enter agentpool name (entersetsdefault) >linux
successful connectasundefined
Retrieved agentpool:linux (2)
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_SESSION_ID=1
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SHELL=/bin/bash
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CLIENT=67.85.54.145 4186 22
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_TTY=/dev/pts/0
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap USER=ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap MAIL=/var/mail/ictfs-admin
Thu Aug13 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 Aug13 2015 14:55:33 GMT+0000 (UTC) : cap PWD=/home/ictfs-admin/build
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LANG=en_US.UTF-8
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap HOME=/home/ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LOGNAME=ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CONNECTION=67.85.54.145 4186 10.0.2.14 22
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LESSOPEN=|/usr/bin/lesspipe %s
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_RUNTIME_DIR=/run/user/1000
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LESSCLOSE=/usr/bin/lesspipe%s%s
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap _=/usr/bin/node
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap OLDPWD=/home/ictfs-admin
Thu Aug13 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 Aug13 2015 14:55:33 GMT+0000 (UTC) : cap ant notfound
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap clangnot found
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap cmake not found
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap curl=/usr/bin/curl
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap gitnot found
3. Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap jake=.
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap javanot found
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap make=/usr/bin/make
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap mdtool notfound
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap mdtool notfound
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap mvnnot found
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap node.js=/usr/bin/node
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap node.js=/usr/bin/nodejs
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap npm=/usr/bin/npm
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap gulpnotfound
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap python=/usr/bin/python
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap python3=/usr/bin/python3
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap sh=/bin/sh
IC-TFS-BA-03Lin
Creatingwork folder...
Creatingenv file ...
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_SESSION_ID=1
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SHELL=/bin/bash
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CLIENT=67.85.54.145 4186 22
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_TTY=/dev/pts/0
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap USER=ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap MAIL=/var/mail/ictfs-admin
Thu Aug13 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 Aug13 2015 14:55:33 GMT+0000 (UTC) : cap PWD=/home/ictfs-admin/build
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LANG=en_US.UTF-8
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap HOME=/home/ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LOGNAME=ictfs-admin
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap SSH_CONNECTION=67.85.54.145 4186 10.0.2.14 22
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LESSOPEN=|/usr/bin/lesspipe %s
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap XDG_RUNTIME_DIR=/run/user/1000
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap LESSCLOSE=/usr/bin/lesspipe%s%s
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap _=/usr/bin/node
Thu Aug13 2015 14:55:33 GMT+0000 (UTC) : cap OLDPWD=/home/ictfs-admin
Savingconfiguration ...
2015-08-13T14:55:33.451Z: AgentStarted.
To quitthe agent,just pressCtrl-C.Youcan alwaysre-startitby runningnode agent/vsoagentagain.