Configuring TeamCity, Maven for PHP for Joomla continuous build
Maven for PHP uses the power of #Maven for building, reporting on and creating documentations of PHP projects. It adapts the #Maven build lifecycle to the PHP world while fully supporting PHP 4 and PHP 5. PHP for #Maven uses PHPUnit for unit testing and doxygen for creating the api documentation.
Use a PHP library project to create a library that can be used by other PHP libraries or PHP web projects. Use a PHP web project to create a standalone web project.
So I quickly describe what I did install on my root server (OpenSuse 11.X)
- Maven 2
- php not an issue on a linux box, zypper in php5 or apt-get to install php
My Objectives: being able to build all my #Joomla! component using best agile development practices
“Specific tools and techniques such as continuous integration, automated or xUnit test, pair programming, test driven development, design patterns, domain-driven design, code refactoring and other techniques are often used to improve quality and enhance project agility.”
While not needed as TeamCity has an integrated Maven engine, I would like to use an external MAVEN version, in order to have the latest version and living dangerously on the edge!
So I download
# wget http://apache.mirror.testserver.li/maven/binaries/apache-maven-2.1.0-bin.tar.gz
# tar xvf apache-maven-2.1.0-bin.tar.gz
Since I would like to avoid having a version number in my configuration build path, I create a symlink
# ln -s apache-maven-2.1.0 maven
I just now tell TeamCity to use my own Maven version, by specifying the Maven Home Path
phpDocumentor is an open source documentation generator written in PHP. It automatically parses PHP source code and produces readable API and source code documentation in a variety of formats. phpDocumentor generates documentation based on PHPDoc-formatted comments and the structure of the source code itself. It supports documentation of both object-oriented and procedural code. phpDocumentor can create documentation in HTML, PDF, CHM or Docbook formats.
Can be installed using PEAR, simply run
# pear upgrade PhpDocumentor downloading PhpDocumentor-1.4.2.tgz ... Starting to download PhpDocumentor-1.4.2.tgz (2,421,028 bytes) ..............................................................................done: 2,421,028 bytes upgrade ok: channel://pear.php.net/PhpDocumentor-1.4.2
Can be installed using PEAR, simply run
# pear upgrade PHPunit
Doxygen is a documentation generator for C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D. It runs on most Unix-like systems, including Mac OS X, as well as on Windows. The first version of Doxygen borrowed some code of an old version of DOC++; later, the Doxygen code was rewritten by Dimitri van Heesch. from www.doxygen.orgwww.doxygen.org
# zypper se doxy Lese installierte Pakete... S | Name | Zusammenfassung | Typ --+------------+----------------------------------------------------+------ | doxygen | Automated C, C++, and Java Documentation Generator | Paket | doxywizard | Graphical User Interface for Doxygen | Paket # zypper in doxygen Herunterladen von Paket doxygen-1.5.5-17.1.x86_64 (1/1), 2,3 M (6,2 M installiert) Lade herunter: doxygen-1.5.5-17.1.x86_64.rpm [fertig] Installiere: doxygen-1.5.5-17.1 [fertig]
Prepare Artifactory by adding new Maven for PHP repositories
As Admin user (you cant go to that links without being an admin!), add 2 new repositories
- id: php-maven-snapshots and url: http://repo1.php-maven.org/snapshot
- id: php-maven-release and url: http://repo1.php-maven.org/release
In Maven settings.xml
In order to use Artifactory at his best (proxy and caching of remote repositories), I have a Maven settings.xml that contains ONLY
# vi /home/teamcity/.m2/settings.xml
<settings> <activeProfiles> <activeProfile>cedric-profile</activeProfile> </activeProfiles> <profiles> <profile> <id>cedric-profile</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>central</id> <url>http://maven.waltercedric.com/artifactory/repo/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>snapshots</id> <url>http://maven.waltercedric.com/artifactory/repo/</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://maven.waltercedric.com/artifactory/plugins-releases/</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>snapshots</id> <url>http://maven.waltercedric.com/artifactory/plugins-snapshots/</url> <releases> <enabled>false</enabled> </releases> </pluginRepository> </pluginRepositories> </profile> </profiles> </settings>
Attention: Artifactory WIKI tell to use http://maven.waltercedric.com/artifactory/plugins-releases and not http://maven.waltercedric.com/artifactory/plugins-releases/ on my HOST with mod_proxy it made an error 404 If I do not add a slash at the end. Try with your host before, you will gain a lot of time by checking if the URL is valid!
Note that http://url:port/artifactory/repo/ is a virtual repositories that proxy all external repositories
Use SolarJoomla (hopefully to be distributed this week) to have a running Eclipse, PDT, Maven 4 PHP environment, Mylyn, TeamCity in no time
First I create a new Maven Project with Archetype “Maven for PHP” “PHP5 libraries”
The first build failed with
[INFO] PHP Warning: require_once(PHPUnit/TextUI/TestRunner.php): failed to open stream: Operation not permitted
This is because of my PHP security restrictions, I only allow file to be opened from /home/teamcity/
So I just add
/home/teamcity/TeamCity/buildAgent/ to my open_basedir in my php.ini ; open_basedir, if set, limits all file operations to the defined directory ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. open_basedir = /srv/www/vhosts:/tmp:/home/teamcity/TeamCity/buildAgent/
To be continued
So long an empty PHP project is building successfully, tomorrow I will try to make a REAL Joomla! component build there!
As soon as It works, and all my Joomla! components are running in TeamCity, I will try to achieve the same goal in Bamboo, why? because it is simply . . .fun!