Download - Continous delivery with Jenkins and Chef

Transcript
Page 1: Continous delivery with Jenkins and Chef

Continous delivery pipeline for Symfony2 projects with

Jenkins and ChefMichał Dąbrowski

http://github.com/defrag PHPers Kraków 10/07/2014

Page 2: Continous delivery with Jenkins and Chef
Page 3: Continous delivery with Jenkins and Chef

Most common anwser?

Page 4: Continous delivery with Jenkins and Chef

Most common anwser?

Should be done

Page 5: Continous delivery with Jenkins and Chef

Most common anwser?

Should be done

Page 6: Continous delivery with Jenkins and Chef

„Continuous delivery (CD) is a set of processes, tools and techniques for the

rapid, reliable and continuous development and delivery of software.”

What is continous delivery?

Page 7: Continous delivery with Jenkins and Chef

Our highest priority is to satisfy the customer!

through early and continuous delivery!of valuable software.

Agile manifesto #1

Page 8: Continous delivery with Jenkins and Chef

done === released

What is done in Continous Delivery?

Page 9: Continous delivery with Jenkins and Chef

Why?increase quality

reduce cost reduct risk

make customer happy delivery production ready software

act on feedback

Page 10: Continous delivery with Jenkins and Chef

Quality comes first

Page 11: Continous delivery with Jenkins and Chef

Building blocks from practical viewContinous IntegrationRelease automation

Infrastructure automationMonitoring

Page 12: Continous delivery with Jenkins and Chef

CI & Deployment pipeline

Page 13: Continous delivery with Jenkins and Chef

Typical development workflow

Fork a repo

Page 14: Continous delivery with Jenkins and Chef

Typical development workflow

Submit pull request

Page 15: Continous delivery with Jenkins and Chef

Typical development workflow

Trigger build process on PR

Page 16: Continous delivery with Jenkins and Chef

Typical development workflow

Code review

Page 17: Continous delivery with Jenkins and Chef

Typical development workflow

Merge into master

Page 18: Continous delivery with Jenkins and Chef

Typical development workflow

Trigger build on master branch

Page 19: Continous delivery with Jenkins and Chef

Typical development workflow

Result of build is Release Candidate!(not every RC is deployed)

Page 20: Continous delivery with Jenkins and Chef

How do we get there?

Page 21: Continous delivery with Jenkins and Chef

Start with Jenkins

Page 22: Continous delivery with Jenkins and Chef

Create new project

Page 23: Continous delivery with Jenkins and Chef

Set up your build process

Page 24: Continous delivery with Jenkins and Chef

Set up your build process

<target name="configure"> <echo>Downloading dependencies using composer.</echo> <exec executable="/bin/bash" failonerror="true" dir=„."> <arg value="/usr/bin/composer install —no-interaction —prefer-dist" />! </exec> ! <echo>Dumping prod assets.</echo> <exec executable="/bin/bash" failonerror="true"> <arg value="-c" /> <arg value="${basedir}/bin/console assetic:dump --env=prod --no-debug" />! </exec> ! <echo>Ensuring empty cache and logs directories.</echo> <delete includeemptydirs="true" verbose="false" failonerror="true" dir="${basedir}/var/cache" />! <delete includeemptydirs="true" verbose="false" failonerror="true" dir="${basedir}/var/logs" />! <mkdir dir="${basedir}/var/cache" />! <mkdir dir="${basedir}/var/logs" /> </target>

Page 25: Continous delivery with Jenkins and Chef

Run your unit tests

Page 26: Continous delivery with Jenkins and Chef

Run your unit tests

<target name=„phpspec" description="Run tests with PHPSpec"> <exec executable="/bin/bash" failonerror="true"> <arg value="-c" /> <arg value="${basedir}/bin/phpspec run" /> </exec> </target>

<target name="build-unit"> <property file="build.ci.properties" /> <antcall target="phpspec" /> ! <antcall target="jasmine" /> <echo>Unit test build pass.</echo> </target>

Page 27: Continous delivery with Jenkins and Chef

Run your acceptance tests

Page 28: Continous delivery with Jenkins and Chef

Run your acceptance tests

<target name=„behat" description=„Run acceptance tests with Behat"> <exec executable="/bin/bash" failonerror="true"> <arg value="-c" /> <arg value="${basedir}/bin/behat —format progress" />! </exec> </target>

<target name="build-acceptance"> <property file="build.ci.properties" /> <antcall target="behat" /> ! <echo>Acceptance test build pass.</echo> </target>

Page 29: Continous delivery with Jenkins and Chef

Create package out of build result

• tarball!• rpm!• deb!• etc.

Page 30: Continous delivery with Jenkins and Chef

Create package out of build result

Page 31: Continous delivery with Jenkins and Chef

Visualize your process with build pipeline

Page 32: Continous delivery with Jenkins and Chef

Stop

Deploy time

Page 33: Continous delivery with Jenkins and Chef

Not only application

Deliver your configuration in automated fashion

Page 34: Continous delivery with Jenkins and Chef

Build pipeline revisited

manualauto

Page 35: Continous delivery with Jenkins and Chef

Quick Chef overview

Page 36: Continous delivery with Jenkins and Chef

Make jenkins talk to your chef server

knife ec2 server create!knife bootstrap!

knife ssh!…

Page 37: Continous delivery with Jenkins and Chef

Make jenkins talk to your chef server

Page 38: Continous delivery with Jenkins and Chef

Deploy appcapistrano, fabric, knife plugin etc

Page 39: Continous delivery with Jenkins and Chef

Chose the one that works for you

Page 40: Continous delivery with Jenkins and Chef

Dead simple with Fabric and pychef

@roles('web')!def deploy(): …

Page 41: Continous delivery with Jenkins and Chef

Dead simple with Fabric and pychef

fab env:staging deploy:25

Page 42: Continous delivery with Jenkins and Chef

Dead simple with Fabric and pychef

fab env:staging deploy:25

chef environment build no.

Page 43: Continous delivery with Jenkins and Chef

Demo

Page 44: Continous delivery with Jenkins and Chef

Wrapping up

Page 45: Continous delivery with Jenkins and Chef

Benefitsspeed of delivery

quality cost reduction

ability to respond to feedback quickly adapt to change

Page 46: Continous delivery with Jenkins and Chef

Thank you