Press "Enter" to skip to content

Richy's Random Ramblings

Running Jenkins CI for PHP on Amazon EC2 [6/7]

Continued from Installing and Configuring Jenkins CI

Make a backup of the Amazon EC2 configuration

  1. Log into your Amazon Ec2 account
  2. Under the “My instances” select your Jenkins install
  3. Under “Instance Actions” to “Create Image (EBS AMI)” and give it an appropriate name and description

It is advisable to shutdown your EC2 image when you are not using it to avoid billing (not so important with the free Micro instance, but a good practice to get into)

Continued in Relaunching the Amazon EC2 image

Running Jenkins CI for PHP on Amazon EC2 [5/7]

Continued from Connecting to Amazon EC2 using PuTTY

Installing and Configuring Jenkins CI

  1. Connect to your Amazon EC2 image as per Connecting to Amazon EC2 using PuTTY
  2. In the SSH window, run: sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  3. In the SSH window, run: sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
  4. In the SSH window, run: sudo yum install jenkins
  5. In the SSH window, run: sudo service jenkins start
  6. Whilst we are waiting for Jenkins to start up, we can install PHP and associated modules
  7. In the SSH window, run: sudo yum install php git
  8. In the SSH window, run: wget http://pear.php.net/go-pear.phar;sudo php go-pear.phar
  9. You will be prompted if you want to make any changes to the PEAR installation. Select to change the “Installation base ($prefix)” 1 to /usr
  10. You will be prompted if “Would you like to alter /etc/php.ini”, select “Yes”
  11. In the SSH window, run: sudo pear config-set auto_discover 1
  12. sudo yum install php-devel gcc make ImageMagick ImageMagick-devel php-dom php-pdo dbus-devel libxml2 libxml2-devel ant php-mbstring swig

  13. In the SSH window, run: sudo pecl install xdebug channel://pecl.php.net/dbus-0.1.1
  14. In the SSH window, run: sudo pear install pear/XML_RPC2 pear.phpqatools.org/phpqatools PHPDocumentor pear.phpunit.de/PHPUnit channel://pear.php.net/Text_Highlighter-0.7.1 channel://pear.phpundercontrol.org/phpUnderControl-0.6.1beta1 channel://pear.php.net/HTTP_Request2-2.0.0RC2 channel://pear.php.net/Net_URL2-0.3.1 pear.pdepend.org/PHP_Depend phpunit/PHP_CodeBrowser channel://pear.docblox-project.org/docblox-0.15.1
  15. In the SSH window, run: sudo su
  16. In the SSH window, run: echo 'zend_extension="/usr/lib64/php/modules/xdebug.so"' >> /etc/php.ini
  17. In the SSH window, run: echo 'extension=dbus.so' >> /etc/php.ini
  18. In the SSH window, run: echo 'date.timezone="Etc/UTC"' >> /etc/php.ini
  19. In your web browser, go to http://ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com:8080 (where http://ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com is the hostname of your Amazon EC2 image)
  20. Click “Manage Jenkins” on the left hand side and then select “Configure system” (in Chrome, you may get the “LOADING…” grey screen covering most things for a long time, just try a different browser)
  21. Select “Enable security”
  22. Under “Access Control->Security Realm” select “Jenkins’s own user database” and tick the “Allow users to sign up”
  23. Under “Authorization” select “Matrix based security”
    • Along side “Anonymous” select “Overall->Read”
    • In “User/group to add” add your preferred username and click “Add”
    • Give yourselves full access by checking the entire row
  24. Scroll down and click “Save”
  25. From the home page of Jenkins click “Sign-up now”
  26. Enter the same username as you did before and your preferred password, name and email address. Click “Sign up”
  27. Once you’ve logged back in, select “Manage Jenkins” and “Manage Plugins”
  28. Select “Available” and check the following plugins:
    • Checkstyle
    • Clover PHP
    • DRY,
    • JDepend
    • Plot
    • PMD
    • Violations
    • Analysis Collector Plugin
    • xUnit

    If you are developing using GitHub, also select “Github Plugin”

  29. Scroll down and click “Install”
  30. Wait and then select “Restart Jenkins when no jobs are running”
  31. Wait whilst Jenkins restarts
  32. Go back to “Manage Jenkins->Configure System”
  33. Scroll down to “Ant” and “Add Ant” and call it “Ant” and select “Install automatically”
  34. Under the “E-mail notification” under the “Default user e-mail suffix” and “@” followed by your domain name and your email address under “System admin e-mail address”
  35. Click Save
  36. Continued in Make a backup of the Amazon EC2 configuration

Running Jenkins CI for PHP on Amazon EC2 [4/7]

Continued from Preparing PuTTY for Amazon EC2

Connecting to Amazon EC2 using PuTTY

  1. Load PuTTY
  2. In the Hostname box, enter the Public DNS entry of your Amazon EC2 instance (ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com)
  3. Click, in the left hand side of the PuTTY window, Connection->SSH->Auth
  4. In the “Private Key Field” select the file you saved from “Preparing PuTTY for Amazon EC2
  5. Click “Open”
  6. Login as “ec2-user”

Continued in Installing and Configuring Jenkins CI

Running Jenkins CI for PHP on Amazon EC2 [3/7]

Continued from Signing up to Amazon EC2 and starting your first image

Preparing PuTTY
Note: These instructions are based on the Windows version of PuTTY and PuTTYgen

  1. Download an install PuTTY and PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/ (if there is an “install all” install for your platform, use that)
  2. Load PuTTYgen
  3. Click Load (“Load an existing private key file”)
  4. Select “Show all files (*.*)” in the “Load” box instead of the “PuTTY Private Key Files (*.ppk)”
  5. Select your Amazon EC2 Key (such as AmazonInstance.pem)
  6. Click Load
  7. You should receive the “Succesfully imported foreign key” message
  8. Click “Save private key” (select Yes to “Are you sure you want to save this key without a passphrase to protect it?”)
  9. Save the file somewhere save

Continued in Connecting to Amazon EC2 using PuTTY