Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Instructions to Setup Teamcity Agent on EC2 Ubuntu 12.04.2 Linux with NodeJS and PhantomJS

How to: Setup Teamcity Agent on EC2 Ubuntu 12.04.2 Linux with front end tools

References:

Install dependencies

sudo apt-get update
sudo apt-get -y install openjdk-7-jre-headless libssl-dev git-core pkg-config build-essential curl gcc g++ checkinstall unzip

Download TeamCity buildAgent.zip

wget http://<your-teamcity-url>/update/buildAgent.zip
unzip buildAgent.zip -d buildAgent
chmod +x buildAgent/bin/agent.sh
cp buildAgent/conf/buildAgent.dist.properties buildAgent/conf/buildAgent.properties

Change needed properties inside buildAgent.properties

You may need to set the originally commented ownAddress property to the public machine address Also, don't forget to open the default port (9090) in the Security Group settings.

vim buildAgent/conf/buildAgent.properties

Create the start script

sudo vim /etc/init.d/teamcity

Add the following contents:

#! /bin/sh
# /etc/init.d/teamcity 
# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting script teamcity "
    /home/ubuntu/buildAgent/bin/agent.sh start
    ;;
  stop)
    echo "Stopping script teamcity"
    /home/ubuntu/buildAgent/bin/agent.sh stop
    ;;
  *)
    echo "Usage: /etc/init.d/teamcity {start|stop}"
    exit 1
    ;;
esac
 
exit 0

Give it proper permissions:

sudo chmod 755 /etc/init.d/teamcity

Add it to the startup process:

sudo update-rc.d teamcity defaults

Install nodejs

Create this script

vim node-install.sh

#!/bin/bash
ver="0.10.6"
echo Installing node version $ver
wget http://nodejs.org/dist/v$ver/node-v$ver.tar.gz
tar -zxf node-v$ver.tar.gz
cd node-v$ver
sudo ./configure && make && checkinstall --install=yes --pkgname=nodejs --pkgversion "$ver" --default

Execute it ( this will take a while )

chmod +x node-install.sh
sudo ./node-install.sh

(For uninstalling, simply sudo apt-get remove nodejs)

Alternatively, you can pick an option from Isaacs' gist to install node.

It's sometimes necessary to alias node and npm to all users in the machine:

sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/bin/grunt /usr/bin/grunt
sudo ln -s /usr/local/bin/phantomjs /usr/bin/phantomjs
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf

Install grunt and phantom

sudo npm i -g grunt-cli phantomjs

Restart and check that the buildAgent is connected on TeamCity Server.

@adamdelarosa

This comment has been minimized.

Show comment Hide comment
@adamdelarosa

adamdelarosa Aug 10, 2015

Great, Thanks.

Great, Thanks.

@edgarhsanchez

This comment has been minimized.

Show comment Hide comment
@edgarhsanchez

edgarhsanchez Apr 4, 2018

you may have to use 8 or 9 for jdk on newer systems

sudo apt-get -y install openjdk-9-jre-headless libssl-dev git-core pkg-config build-essential curl gcc g++ checkinstall unzip

you may have to use 8 or 9 for jdk on newer systems

sudo apt-get -y install openjdk-9-jre-headless libssl-dev git-core pkg-config build-essential curl gcc g++ checkinstall unzip

@saidAlizadeh

This comment has been minimized.

Show comment Hide comment
@saidAlizadeh

saidAlizadeh Apr 13, 2018

I'm a newbis.
What does "nodejs" and "grunt"? Are they necessary to make auto start on tc agent?
Is't update-rc enogh to let agent be started by system running the script contained in init.d?

I'm a newbis.
What does "nodejs" and "grunt"? Are they necessary to make auto start on tc agent?
Is't update-rc enogh to let agent be started by system running the script contained in init.d?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment