Keith Casey did a talk a talk on Continuous Integration with Jenkins at Sunshine PHP. The first half of the talk was devoted to getting Jenkins installed on our laptops. In a room full of Mackbook Pros, I was one of the few Windows desktops. What follows is my experience with getting it working.
Keith talked about a lot of tools which help to check code quality including
- Lint
- Phing
- CodeSniffer
- PHPCPD
- PHPMD
- PHPLOC
Install PHP and Pear
- Download PHP and install it to c:\php. Add c:\php to your PATH variable.
- Download go-pear.phar and save it to c:\php. The information for that is here.
- Open an Administrative command prompt
- CD to c:\php and run php go-pear.phar. Press enter through all the prompts. Now you have Pear.
- Paste the entire giant blob of code into your Administrative command prompt
REM install phpunit
pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
REM install phpqatools
pear config-set auto_discover 1
pear install pear.phpqatools.org/phpqatools
REM install phing
pear channel-discover pear.phing.info
pear install phing/phing-alpha
REM add PSR codesniffer
cd c:\php\pear\php\CodeSniffer\Standards
git clone https://github.com/klaussilveira/phpcs-psr PSR
phpcs --config-set default_standard PSR
Pear will park .bat files in c:\php for all the modules you installed. Notice that phing is installed as phing-alpha. This is only necessary until 2.7.0 is promoted to stable.
You also need to install Git for Windows. Use MsyGit and pick “Git from Windows command prompt”.
Lastly, edit your php.ini and enable the extension php_xsl.dll
Install Jenkins
This was pretty straight forward. It’s a Java based project, and there is a Windows installer. Make sure to run the setup.exe, not the MSI.
Once Jenkins is installed, connect to http://localhost:8080/. If the Jenkins dashboard opens, it works!
The web2project example
Keith used one of his own projects, web2project, to demonstrate Jenkins. Getting the toolchain working on windows was a challenge.
- Login to the web console
- Click Manage Jenkins –> Manage Jenkins
- Under Updates, click available updates
- Install: Git, Github, PMD, Phing, CPD. A restart of the jenkins service may be necessary
- Go back to the dashboard
- Click New Job –> Build a freestyle project called web2project
- Under source code management, pick git and use the path http://github.com/web2project/web2project
- Under build pick a custom windows batch command and fill in: cd unit_tests & phing metrics
- Click save and build now
Recent Comments