Note: You may want to see my Teamcity server guide as well: http://peterjolson.com/installing-teamcityyoutrack-in-a-tomcat-container-with-tomcat-virtual-host-smartos-vm/

Getting Started.

I started with http://wiki.joyent.com/wiki/display/jpc2/Java+Instance.

svcadm disable tomcat #we won't use this

Install php and other needed stuff (some of this may not be nessisary, but why not).

pkgin in php55-pear php55-dom nano gmake gcc47 autoconf php-5.5 php55-mysqli php55-mcrypt php55-mbstring unzip php55-zlib php55-gd php55-zip php55-curl php55-imap php55-json php55-mysql php55-pdo_mysql php55-bcmath php55-fpm nano php55-dom php55-xmlrpc php55-posix php55-pcntl php55-iconv  

Xdebug is a installed with pecl pecl install xdebug

Add the stuff below to the bottom of nano /opt/local/etc/php.ini:

zend_extension=xdebug.so  
extension=dom.so  
extension=pdo.so  
extension=mysqli.so  
extension=mcrypt.so  
extension=mbstring.so  
extension=zlib.so  
extension=gd.so  
extension=zip.so  
extension=curl.so  
extension=imap.so  
extension=json.so  
extension=pdo_mysql.so  
extension=bcmath.so  
extension=xmlrpc.so  
extension=posix.so  
extension=pcntl.so  
extension=iconv.so  

Install a bunch of stuff we can use later with Teamcity (I don't know if you need this on the build agent server, or the teamcity server, I have this on both):

pear channel-discover pear.phpdoc.org  
pear channel-discover bartlett.laurent-laville.org  
pear channel-discover components.ez.no  
pear channel-discover pear.symfony-project.com  
pear channel-discover pear.pdepend.org  
pear channel-discover pear.phpmd.org  
pear channel-discover pear.phing.info

pear install pear.phpunit.de/PHPUnit  
pear install bartlett/PHP_CompatInfo  
pear install --alldeps PHP_Codesniffer  
pear install pdepend/PHP_Depend-beta  
pear install phpmd/PHP_PMD  
pear install phpunit/phpcpd  
pear install phpunit/phpdcd-beta  
pear install phpdoc/phpDocumentor-alpha  
pear install [--alldeps] phing/phing  
pear install phpunit/PHPUnit_Story  

Note: Pear is not the supported method anymore. Teamcity will just download the phar by default.

If you want a webserver (optional)

If your doing a webserver, see my helpers here: https://github.com/that0n3guy/smartos-zone-teamcity-agent

Install nginx: pkgin in nginx

Disable and remove apache, we don't need it.

svcadm disable apache  
pkgin remove apache  

Enable nginx and php-fpm:

svcadm enable nginx  
svcadm enable php-fpm  
sudo mkdir -p /opt/local/etc/nginx/sites-enabled  
sudo mkdir -p /opt/local/etc/nginx/sites-available  

On Your Teamcity Server

Back on your teamcity server
install meta-runner-power-pack(https://github.com/JetBrains/meta-runner-power-pack):

  • go to root home
  • clone repo
  • copy php metaRunners to _Root project (so it can be used on all projects)
cd ~ # go to root home  
git clone https://github.com/JetBrains/meta-runner-power-pack.git  
mkdir /opt/teamcity/teamcity_data/config/projects/_Root/pluginData/metaRunners  
cd /opt/teamcity/teamcity_data/config/projects/_Root/pluginData/metaRunners  
cp ~/meta-runner-power-pack/php/* ./  

Create some ssh keys:

mkdir /opt/teamcity/ssh  
cd /opt/teamcity/ssh  
ssh-keygen -t rsa #I called my key teamctiy_agents, sorted in this folder  
cat {yourKeynameNere}.pub #Just so we can read it.  

Back on Build Agent Server:

Lets add the ssh keys:
vi /home/admin/.ssh/authorized_keys #add a public key that you just generated

Had one error about SSL, found there error here: https://github.com/JetBrains/meta-runner-power-pack/issues/31. I used https://github.com/that0n3guy/smartos-zone-teamcity-agent/blob/master/fix-ssl-error.sh:

We need to set a different JAVA_HOME than the server normally has, because this is the java that will be used for builds: export JAVA_HOME=/home/admin/BuildAgent/jre/

Download and run the fix script:

wget https://raw.githubusercontent.com/that0n3guy/smartos-zone-teamcity-agent/master/fix-ssl-error.sh  
bash fix-ssl-error.sh  

On Teamcity web interface:

Create "Agent push" preset.
Create agent with push using the SSH key and filepath you created.

Tips

  • I put have by build server on a private network behind a firewall. The Teamcity server can communicate directly with it.
  • If I want to actually see the webserver, I add my url to my firewalls reverse proxy.
  • for x2engine, I also had to uncomment session.save_path = "/tmp" from my php.ini file.
  • if you want mysql comman line unitilities

References: - http://kogentadono.com/2012/05/11/part-1-setting-up-teamcity-for-php-ci-installing-tc/ - http://confluence.jetbrains.com/display/TCD8/Getting+started+with+PHP

Off topic: when installing the build agent On windows: Tested build agent on my local computer: setup router to forward 9090 to my IP. Had to add an extra line of my local config here ownAddress=98.172.143.243 (had to do this in the text file, not using the installer. The installer added an extra space).