1. Continuous integration

Continuous integration

Introduction

As part of the Agile process we will utilise CI as much as possible.

Creating BDD unit tests through Jasmine and automating these is vital for a smooth running of the development cycle.

We can also utilise this for building and deploying the apps to the various test devices.

Software

  • Jenkins is the industry standards in terms of self hosted CI software. Although there are now other competitors to this.
  • Team City Offer a more premium CI studio for modern development practices.
  • Ansible Works

Either of these are compatible with Mac OSX Server

Thor

Within each project is a Thor script. This provides a means to conduct local CI and should be updated in regards to what happened on the Jenkins Instance.

Please read the Thor wiki page for more information

Todo

  • Set-up a Jenkins instance on the server to lint, build and test the app and site.
  • Check out Ansible Works more
  • Check out Team City more

Develop Branch Some would call this the "integration branch". This is where any automatic nightly builds are built from.

CI Server

  • Version :
  • Domain : Jenkins
  • SSH Config name : aftools

Installation

On Debian based machines it is best to install through apt-get

Add the Key

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

Then add the following entry into sources

sudo nano /etc/apt/sources.list
deb http://pkg.jenkins-ci.org/debian binary/

Update local package index, then finally install Jenkins

sudo apt-get update
sudo apt-get install jenkins
sudo apt-get install ant
sudo apt-get install git

Create Job

sudo su - jenkins

Basically a Job should pull from the SCM, Process and then Copy to the destination server

Exclude certain folders and files from being pushed to the server

  • README.md
  • .gitattributes
  • .gitgnore

Features

PHP CodeSniffer PHP_CodeSniffer is a PHP5 script that tokenises and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.

PHP Unit PHPUnit is the de-facto standard for unit testing in PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results.

PHP Depend - Performs static code analysis on a given source base.

PHP Mess Detector - PHPMD can be seen as an user friendly and easy to configure frontend for the raw metrics measured by PHP Depend.

PHP Copy Paste Detect - PHPCPD is a Copy/Paste Detector (CPD) for PHP code.

PHP LOC - PHPLOC is a tool for quickly measuring the size and analyzing the structure of a PHP project.

Doxygen - Doxygen is a documentation system for C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D.

Configuration

  • Add System Message "Welcome to our Continuous Integration Server"
  • Enable Security
    • Security Realm : Jenkins's own user database
      • Make sure Allows Users to Sign Up is checked
    • Authorisation : Matrix Based security
      • Create initial User Name i.e. iwarner - Give all options
    • Prevent Cross Site Request
      • Check All Crumb options
    • Save - you will be logged out
  • Create Account
    • This should be the same as the username in the Authorisation step
    • Un check the Allows Users to Sign UP - save
    • Additional user will need to be added to the Matrix
  • Disable Plugins
    • May need to take of crumb control for this
    • Subversion plugin
    • CVS plugin
    • Translation
    • LDAP
    • Maven
    • JavaDoc
  • Install Plugins
    • GIT
  • Add JDK
    • Un-check Install Automatically
    • Name : java-1.7.0-openjdk-amd64
    • JAVA_HOME : /usr/lib/jvm/java-1.7.0-openjdk-amd64
  • SSH Key
    • To copy to another Amazon instance add the id_rsa.pub key to the Authorised Keys file on the remote machine
  • Rsync Connection to staging / production server
    • rsync -e 'ssh -p 2222' -Cavz /var/lib/jenkins/jobs/AlphaFounders\ -\ Vagrant/workspace/ [email protected]:/data/www/alphafounders.com/
    • Options
      • -e - Specify SSH on port 2222
      • -C - auto-ignore files the same way CVS does
      • -a - archive mode; same as -rlptgoD (no -H)
        • recurse into directories
        • copy symlinks as symlinks
        • preserve permissions
        • preserve times
        • preserve group
        • preserve owner (super-user only)
        • same as –devices –specials
      • -v - increase verbosity
      • -z - compress file data during the transfer

ANT

For all jobs we will use ANT