continuous delivery with gradle

50
CONTINUOUS DELIVERY WITH GRADLE / / BOB PAULIN @BOBPAULIN [email protected]

Upload: bob-paulin

Post on 26-May-2015

989 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Continuous delivery with Gradle

CONTINUOUS DELIVERYWITH GRADLE

/ / BOB PAULIN @BOBPAULIN [email protected]

Page 2: Continuous delivery with Gradle

ABOUT MEIndependent ConsultantBusiness EnablementWeb Centric PlatformsAutomation

Page 3: Continuous delivery with Gradle

I LOVE DELIVERING SOFTWARE

I WANT TO DELIVER SOFTWARE ALL THE TIME!

MULTIPLE TIMES A DAY!

Page 4: Continuous delivery with Gradle

WAIT PEOPLE ACTUALLY DO THAT?

Page 5: Continuous delivery with Gradle

SEVERAL MAJOR ECOMMERCE SHOPSETSY.COM DEPLOYS ABOUT 30 TIMES EACH DAY

MY PERSONAL RECORD 5

Page 6: Continuous delivery with Gradle

BENEFITS OF CONTINUOUS DELIVERYShorten the time it takes from conception to customer impactExperiment more frequentlyDo more concurrentlyDelivery becomes a non-event

Page 7: Continuous delivery with Gradle

DELIVERING SOFTWARE CAN BE PAINFUL!Needs to be AssembledNeeds to be DeployedNeeds to be TestedHow can I make sure I don't break existing stuff?What happens if I do break something?What about dependent systems?How do I know what changed?How do I control what goes in and what does not?

Page 8: Continuous delivery with Gradle

ALL THAT'S GOING TO TAKE ME AT LEAST 2WEEKS!

Page 9: Continuous delivery with Gradle

RELEASE MANAGEMENT 101Consistent Build ProcessFunctional/Regression TestingVersioningSource Code ManagementDeployment ProcessRollback

Page 10: Continuous delivery with Gradle

RELEASE MANAGEMENT 501Config SwitchesFeature BranchingModular DeploymentThrottlingAuto ProvisioningAuto-Scaling

Page 11: Continuous delivery with Gradle

TOOLS TO THE RESCUE!

Page 12: Continuous delivery with Gradle

BUILD TOOLS

Page 13: Continuous delivery with Gradle

Dependency ManagementPackagingPlugin ArchitectureLifecycle ManagementVersioning

Page 14: Continuous delivery with Gradle

A RECIPE FOR CONTINUOUS DELIVERYGradleArtifactoryGit

Page 15: Continuous delivery with Gradle

GRADLEBuild ToolGroovyCombines some of the best features of Ant and MavenConventionsPlugins

Page 16: Continuous delivery with Gradle

ARTIFACTORYBinary RepositoryJEE Web AppSupports Maven and IvyOpen Source and Pro Licensed

Page 17: Continuous delivery with Gradle

GITSource Control ManagementDistributedTagging/Branch/Merge

Page 18: Continuous delivery with Gradle

HOW DOES ALL THIS STUFF WORKTOGETHER?

Page 19: Continuous delivery with Gradle

STEPS

Page 20: Continuous delivery with Gradle

SYSTEM INTERACTION

Page 21: Continuous delivery with Gradle

A BRIEF ASIDE ON SEMANTIC VERSIONING

Page 22: Continuous delivery with Gradle

LETS LOOK AT SOME CODE!

Page 23: Continuous delivery with Gradle

GRADLE PLUGINSWar PluginCargo PluginMaven Plugin

Page 24: Continuous delivery with Gradle

GRADLE CONFIGURATIONSCONFIG + CODE!

Page 25: Continuous delivery with Gradle

cargo { containerId = 'tomcat7x' port = Integer.parseInt(getProperty(project.env + ".deployPort"))

deployable { context = artifactId file = project.file(artifactDownloadPath) } remote { hostname = getProperty(project.env + ".deployHostname") username = getProperty(project.env + ".deployUserName") password = getProperty(project.env + ".deployPassword") } }

Page 26: Continuous delivery with Gradle

DON'T EMBED ENVIRONMENT DATA INTO THEBUILD SCRIPT!

CREATE A USER PROPERTIES FILE INSTEAD.

Page 27: Continuous delivery with Gradle

DEPENDENCY MANAGEMENTFOR YOUR APPLICATION AND FOR YOUR BUILD

Page 28: Continuous delivery with Gradle

buildscript { repositories { maven { url "https://oss.sonatype.org/content/groups/public"} mavenCentral() }

dependencies { classpath "javax.servlet:servlet-api:2.5", "org.gradle.api.plugins:gradle-cargo-plugin:0.6.1", "org.ajoberstar:gradle-git:0.6.3" }}

Page 29: Continuous delivery with Gradle

dependencies { def cargoVersion = '1.3.3' def springVersion = '3.2.3.RELEASE' def wro4JVersion = '1.6.3' def aopAllainceVersion = '1.0' cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion", "org.codehaus.cargo:cargo-ant: compile "org.springframework:spring-aop:$springVersion", "org.springframework:spring-beans: "org.springframework:spring-context:$springVersion","org.springframework:spring-context-support: "org.springframework:spring-expression:$springVersion", "org.springframework:spring-tx: "org.springframework:spring-web:$springVersion", "org.springframework:spring-webmvc: "javax.servlet:jstl:1.2","org.slf4j:slf4j-api:1.5.6", "org.slf4j:jcl-over-slf4j:1.5.6" "org.codehaus.jackson:jackson-mapper-asl:1.9.3","aopalliance:aopalliance:$aopAllainceVersion compile("org.springframework.data:spring-data-mongodb:1.0.4.RELEASE"){ exclude module: "slf4j-api" } compile("org.springframework:spring-core:$springVersion"){ exclude module: 'commons-logging' } compile ("ro.isdc.wro4j:wro4j-core:$wro4JVersion") { exclude module: "slf4j-api" } compile("ro.isdc.wro4j:wro4j-extensions:$wro4JVersion") { exclude module: "slf4j-api" exclude module: "slf4j-log4j12" } providedCompile "javax.el:el-api:1.0", "javax.servlet.jsp:jsp-api:2.0", "javax.servlet:servlet-api:2.5" testCompile "junit:junit:3.8.1", "org.springframework:spring-test:$springVersion

}

Page 30: Continuous delivery with Gradle

GRADLE TASKS

Page 31: Continuous delivery with Gradle

task updateUploadedPom(dependsOn: 'getBranchName') << { def pomVersion = project.version if(!project.getGradle().getTaskGraph().hasTask(":release")) pomVersion += ".$branchName" uploadArchives.repositories.mavenDeployer.pom.version = pomVersion}

Page 32: Continuous delivery with Gradle

task tag(type: GitTag) { tagName = version message = "Release of ${version}"}

task pushToRemote(type: GitPush){ pushAll = true}

Page 33: Continuous delivery with Gradle

task qaRelease { dependsOn test, war, getBranchName, updateUploadedPom, uploadArchives, updateVersionNumber, addVersion}

Page 34: Continuous delivery with Gradle

GRADLE TASK DEPENDENCIES

Page 35: Continuous delivery with Gradle

//Task Dependencieswar.mustRunAfter testtag.mustRunAfter warupdateUploadedPom.mustRunAfter taguploadArchives.mustRunAfter updateUploadedPomupdateVersionNumber.mustRunAfter uploadArchivesaddVersionUpdate.mustRunAfter updateVersionNumbercommitVersionUpdate.mustRunAfter addVersionUpdatepushToRemote.mustRunAfter commitVersionUpdate

Page 36: Continuous delivery with Gradle

DEMO TIME!A SIMPLE BOOK REVIEW WEBSITE

Page 37: Continuous delivery with Gradle

ADDING BOOK RATINGS SCORE TO THE SITE

Page 38: Continuous delivery with Gradle

CREATING A FEATURE BRANCH

Page 39: Continuous delivery with Gradle

WRITE THE CODE... WE ALREADY KNOW HOWTO DO THIS!

Page 40: Continuous delivery with Gradle

BUILD PROCESSWhen you say you're code is done the fun is just beginning...

Page 41: Continuous delivery with Gradle

TESTING PROCESSAre you sure you're done?

Page 42: Continuous delivery with Gradle

RELEASE PROCESSYup we're done!

Page 43: Continuous delivery with Gradle

DEPLOYMENT PROCESSOh yeah now we're done

Page 44: Continuous delivery with Gradle

AN ASIDEWhy is deploy separate from release?

Page 45: Continuous delivery with Gradle

DEPLOYMENT PROCESS: TAKE 2Oh ****! What have we done?!?!

Page 46: Continuous delivery with Gradle

KNOW YOUR ROLLBACK STRATEGY BEFOREEVERY DEPLOYMENT

Page 47: Continuous delivery with Gradle

ENTERPRISE ARCHITECTURE

Page 48: Continuous delivery with Gradle

SOME PARTING THOUGHTS ON GRADLE ANDCONTINOUS DELIVERY