In this talk, I will discuss our experiences at Mollie with setting up the Jenkins Continuous Integration server for all our PHP projects. The talk will be aimed at developers with little or no experience with CI.
3. • Payment Service Provider
• iDEAL, Pay-per-call, Premium SMS, etc.
• SMS gateway
• HTTP API, SMPP, Email to SMS, etc.
• Located in Amsterdam, near Vondelpark
• Four developers
4. Codebase 1/2
• Main project: 250K LOC
• New code is pretty good, but...
• lots of code created around 2004
(when magic_quotes was cool)
5. Codebase 2/2
• Git as SCM
• Also:
• Plugins for OpenCart, Magento, WHCMS
• Example API classes
• Internal projects
8. Theory
In software engineering, continuous integration (CI)
implements continuous processes of applying quality control
— small pieces of effort, applied frequently. Continuous
integration aims to improve the quality of software, and to
reduce the time taken to deliver it, by replacing the
traditional practice of applying quality control after
completing all development. (source:Wikipedia)
10. Why is it useful? 1/2
• All tests are run after every commit.
• You always know if you can deploy after a
commit.
• You know who broke a test.
11. Why is it useful? 2/2
• You can get pretty graphs
• Provides trends
• Motivational for developers
• First step to deploying from SCM
• No more “works for me”.
35. Vagrant
• Create and configure
lightweight,
reproducible, and
portable development
environments.
• Works with
VirtualBox and Chef
36. Vagrant
• Allows you create VMs and deploy them
with software from a Chef recipe.
• Many open source Chef recipes available.
• https://github.com/fnichol/chef-jenkins
38. Chef recipe
%w{pdepend/PHP_Depend-beta phpmd/
PHP_PMD-alpha phpunit/phpcpd phpunit/
phploc phpunit/test_helpers
PHPDocumentor PHP_CodeSniffer
digitalsandwich/Phake phpunit/
PHP_CodeBrowser phpunit/PHPUnit}.each
do |pear_package|
php_pear pear_package do
options "--alldeps"
action :install
end
end
39. Install PHP specific stuff
• Jenkins PHP manual and templates provided
by Sebastian Bergmann.
• http://jenkins-php.org/
40. Tell Jenkins what to do
• Create build.xml
• Lives in your code
• Create a Job in Jenkins
• Point to your SCM
41.
42. Configure Jenkins
• After running build.xml, lots of XML files
are generated.
• You can install plugins in Jenkins which
understand these XML files
• Configure Jenkins plugins to read these files
and “publish” them.
• Optionally: do some stuff after build
succeeds.
47. Don’t run more than
you need
• Consider if you want to wait every build on
phpmd, pdepend etc.
• Alternatively: clone your job and run tests
only in one job and analysis in other job.
48. Use SCM tags
• Jenkins can push tags to your SCM if a build
succeeds
• Combined with tags on deploy very
convenient
49. Make sure production
& Jenkins are identical
• Different platforms? --> Bugs.
• Different PHP versions? --> Bugs.
• Different MySQL versions? --> Bugs.