Ubuntu TeamCity Mono Build Agent

Some quick notes from setting up a TeamCity mono build agent on Ubuntu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

# THESE ARE NOTES, NOT TESTED AS SCRIPT!

# We need the following to get and run teamcity agent
sudo apt-get install openjdk-7-jre-headless
sudo apt-get install unzip #For unzipping buildAgent.zip

# For compiling Simple.Web
sudo apt-get install ruby1.9.1

# We need the following for compiling mono
sudo apt-get install build-essential #For compiling source
sudo apt-get install autoconf #Should get automake
sudo apt-get install libtool
sudo apt-get install gettext
sudo apt-get install mono-complete #Believe it or not,  we need Mono to build Mono

# Get build agent from TC server and unpack in /var/TeamCity
(cd ~/; wget http://teamcity.cloudapp.net/update/buildAgent.zip)
(cd /var; sudo mkdir TeamCity; cd TeamCity)
sudo unzip ~/buildAgent.zip
(cd bin; sudo chmod +x agent.sh)
(cd ../conf; sudo cp buildAgent.dist.properties buildAgent.properties)

# We need to configure the agent
### Change the TeamCity URL (e.g. "http://teamcity.cloudapp.net") and specify a name (e.g. "monotcagent")
sudo vi buildAgent.properties

### We need to tell the machine to start our agent when it boots, like this:
### #!/bin/bash
### /etc/TeamCity/bin/agent.sh start
sudo vi /etc/init.d/teamcity
sudo chmod +x /etc/init.d/teamcity
sudo update-rc.d teamcity defaults

# Lets compile mono from source (if we aren't happy with the version coming from apt-get mono-complete)
cd ~/
(mkdir code; cd code)
(git clone git://github.com/mono/mono.git; cd mono; git checkout mono-3.0.3)
./autogen.sh --prefix=/usr/local
make
make install

# Make sure NuGet.exe knows whos certs to trust
sudo mozroots --import --sync

# We need to open port 9090 so our server can talk to our agent
sudo iptables -A INPUT -p tcp -d 0/0 -s <ip address of your teamcity server>/255.255.255.255 --dport 9090 -j ACCEPT

# Lets reboot to ensure compiled Mono is system default
sudo /sbin/shutdown -r now

# You can always start/stop the agent manually
sudo /var/TeamCity/bin/agent.sh stop
sudo /var/TeamCity/bin/agent.sh start

Comments