Jenkins on Windows 7

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

Install PHP and Pear

  1. Download PHP and install it to c:\php. Add c:\php to your PATH variable.
  2. Download go-pear.phar and save it to c:\php. The information for that is here.
  3. Open an Administrative command prompt
  4. CD to c:\php and run php go-pear.phar. Press enter through all the prompts. Now you have Pear.
  5. Paste the entire giant blob of code into your Administrative command prompt
REM install phpunit
pear channel-update
pear upgrade-all
pear channel-discover
pear channel-discover
pear channel-discover
pear update-channels

REM install phpqatools
pear config-set auto_discover 1
pear install

REM install phing
pear channel-discover
pear install phing/phing-alpha

REM add PSR codesniffer
cd c:\php\pear\php\CodeSniffer\Standards
git clone 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.

  1. Login to the web console
  2. Click Manage Jenkins –> Manage Jenkins
  3. Under Updates, click available updates
  4. Install: Git, Github, PMD, Phing, CPD. A restart of the jenkins service may be necessary
  5. Go back to the dashboard
  6. Click New Job –> Build a freestyle project called web2project
  7. Under source code management, pick git and use the path
  8. Under build pick a custom windows batch command and fill in: cd unit_tests & phing metrics
  9. Click save and build now

About robertlabrie
DevOps Engineer at The Network Inc in metro Atlanta. Too many interests to list here, check out my posts, or look me up on LinkedIn

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: