• Share
  • Email
  • Embed
  • Like
  • Private Content
Continuous delivery-with-maven
 

Continuous delivery-with-maven

on

  • 25,371 views

Maven is close to ubiquitous in the world of enterprise Java, and the Maven dependency ecosystem is the de facto industry standard. However, the traditional Maven build and release strategy, based on ...

Maven is close to ubiquitous in the world of enterprise Java, and the Maven dependency ecosystem is the de facto industry standard. However, the traditional Maven build and release strategy, based on snapshot versions and carefully planned releases, is difficult to reconcile with modern continuous delivery practices, where any commit that passes a series of quality-control gateways can qualify as a release. How can teams using the standard Maven release process still leverage the benefits of continuous delivery? This presentation discusses strategies that can be used to implement continuous delivery solutions with Maven and demonstrates one such strategy using Maven, Jenkins, and Git.

Statistics

Views

Total Views
25,371
Views on SlideShare
18,200
Embed Views
7,171

Actions

Likes
75
Downloads
682
Comments
5

29 Embeds 7,171

http://java.dzone.com 3468
http://weblogs.java.net 3121
http://www.wakaleo.com 356
https://twitter.com 47
http://wakaleo.com 46
http://www.javasight.com 22
http://www.java.net 18
http://architects.dzone.com 16
http://elcurator.octo.com 16
http://mascix.blogspot.com 12
http://131.253.14.98 7
http://www.linkedin.com 6
http://prototrophy15.swaltsu.com 5
http://johnsmart2.rssing.com 5
https://si0.twimg.com 4
https://www.google.com 4
http://cafe.naver.com 2
http://rritw.com 2
http://127.0.0.1 2
http://131.253.14.66 2
http://webcache.googleusercontent.com 2
http://digg.com 1
http://cloud.feedly.com 1
http://www.twylah.com 1
http://172.16.10.165 1
http://stage.java.net 1
http://mascix.blogspot.co.uk 1
http://www.dzone.com 1
http://javasight.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

15 of 5 previous next Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Where can we find video of this presentation? The given link https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=2822 is not working.
    Thanks
    Are you sure you want to
    Your message goes here
    Processing…
  • A very good real life example about how to implement a working build pipeline. I've got a view quistions though..
    I unterstand that setting the version within the jenkins build is neccessary in order not to commit to trunk after a successful build, whic would retrigger the build pipeline eventually. Having that in mind, git is very comfortable. unfortunately I'm using svn, which seem to make a different approach maybe with other tools mandatory. Do you have some tips or thought about this?

    What I still don't like about the pipeline concept and that it drops the concept of snapshot-versions, is that every commit creates a new version jar in my artifactory. This tends to consume much space on the server. This is good and neccessary if you deploy every little change directly and fully automatically. But for me a weekly deployment is fully satisfying.
    Are you sure you want to
    Your message goes here
    Processing…
  • What is the configuration of gol-deploy-to-prod ?
    Are you sure you want to
    Your message goes here
    Processing…
  • I prepared a template project on bitbucket http://bitbucket.org/rlogiacco/atdd, may be it is going to be useful
    Are you sure you want to
    Your message goes here
    Processing…
  • This is perfect, but I want to suggest to use the maven-failsafe-plugin to run your integration tests rather than surefire to help developers run integration tests when needed: this way you can use the cargo plugin to start and stop the container on the developer machine before and after the tests are executed having an automation for developers as well for Jenkins.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Continuous delivery-with-maven Continuous delivery-with-maven Presentation Transcript

    • Real-World Strategies for Continuous Delivery with Maven and Jenkins John Ferguson Smart
    • Consulta nt Trainer Mentor Author Speaker CoderJohn Fer guson S mar t
    • Continuous Delivery Getting value to the business. Fast. 3
    • But what is Continuous Delivery? A build tool? A CI tool? Automated tests? Automated quality? Automated deployment?
    • Yes...and No
    • Continuous Delivery is an attitude
    • Deliver business value more frequently
    • Value can also come in the form of fast feedback
    • Give power back to the business
    • The ‘eternal beta’ strategy
    • Principles of Continuous Delivery
    • Principle #1Every build is a potential release
    • Principle #2Eliminate manual bottlenecks
    • Principle #3Automate wherever possible
    • Principle #4Have automated tests you can trust
    • Build PipelinesThe conveyer belts of Continuous Delivery
    • Compile and unit test Package and deploy DEV Acceptance tests Deploy to QA QA Deploy to PROD PROD
    • Compile and unit testEach commit is a potential release Package and deploy DEV Acceptance tests Deploy to QA QA Deploy to PROD PROD
    • Compile and unit test Package and deploy DEV Acceptance testsWe reuse the same binaries Deploy to QA QA Deploy to PROD PROD
    • Compile and unit test Package and deploy DEV Acceptance testsAutomated tests give us confidence in our build Deploy to QA QA Deploy to PROD PROD
    • Compile and unit test Package and deploy DEV Acceptance testsAutomated, repeatable deployments QA Deploy to QA Deploy to PROD PROD
    • Continuous Delivery with Maven Why does it have to be so hard?!
    • The Maven lifecycle compile test-compile test package integration-test verify install deploy
    • The Maven lifecycleCompile and unit test mvn test compile test-compile test Integration tests mvn verify compile test-compile test package integration-test verify
    • The Maven lifecycleCompile and unit test mvn test compile test-compile test compile test-compile Integration tests mvn verify test package integration-test verifyDeploy to repository compile mvn deploy test-compile test package integration-test verify deploy
    • The Maven Release Process 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT mvn release 1.0.0
    • The Maven Release Process mvn release:prepare• Check that there are no uncommitted changes in the sources• Check that there are no SNAPSHOT dependencies• Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)• Transform the SCM information in the POM to include the final destination of the tag• Run the project tests against the modified POMs to confirm everything is in working order• Commit the modified POMs• Tag the code in the SCM with a version name (this will be prompted for)• Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)• Commit the modified POMs
    • The Maven Release Process mvn release:prepare compiletest-compile test package 1.0.0 integration-test verify 1.0.1-SNAPSHOT1.0.0-SNAPSHOT 1.0.1-SNAPSHOT
    • The Maven Release Process mvn release:perform compile test-compile test 1.0.0 package integration-test verify install deploy 1.0.0
    • The Maven Release ProcessMaven: You build a new release whena snapshot build is good enough Continuous Delivery: Any build is a potential release
    • Options?Make Maven work for you
    • Beware duplication!Build and unit test mvn test Integration tests mvn verify Code coverage... mvn site
    • Minimize build jobs for the main build Default build mvn install compile test integration-test verify install
    • Split unit and integration tests            <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId>maven-surefire-plugin</artifactId>                 <version>2.11</version>                 <configuration>                     <skip>true</skip>                 </configuration>                 <executions>                     <execution>                         <id>unit-tests</id>                         <phase>test</phase>                         <goals>                             <goal>test</goal>                         </goals>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>**/When*.*</include>                             </includes>                             <excludes>                                 <exclude>%regex[.*integration.*When.*]</exclude>                             </excludes>                         </configuration>                     </execution>                     <execution>                         <id>integration-tests</id>                         <phase>integration-test</phase>                         <goals>                             <goal>test</goal>                         </goals>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>%regex[.*integration.*]</include>                             </includes>                         </configuration>                     </execution> Using package conventions                 </executions>             </plugin>
    • Split unit and integration tests                <groupId>org.apache.maven.plugins</groupId>            <plugin>                 <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-surefire-plugin</artifactId>                 <artifactId>maven-surefire-plugin</artifactId>                <version>2.11</version>                 <version>2.11</version>                <configuration>                 <configuration>                     <skip>true</skip>                    <skip>true</skip>                 </configuration>                </configuration>                 <executions>                     <execution>                         <id>unit-tests</id>                         <phase>test</phase>                         <goals>                             <goal>test</goal>                         </goals>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>**/When*.*</include>                             </includes>                             <excludes>                                 <exclude>%regex[.*integration.*When.*]</exclude>                             </excludes>                         </configuration>                     </execution>                     <execution>                         <id>integration-tests</id>                         <phase>integration-test</phase>                         <goals>                             <goal>test</goal>                         </goals>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>%regex[.*integration.*]</include>                             </includes>                         </configuration>                     </execution> Using package conventions                 </executions>             </plugin>
    • Split unit and integration tests            <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId>maven-surefire-plugin</artifactId>                    <execution>                 <version>2.11</version>                 <configuration>                        <id>unit-tests</id>                     <skip>true</skip>                        <phase>test</phase>                 </configuration>                        <goals>                 <executions>                     <execution>                            <goal>test</goal>                         <id>unit-tests</id>                        </goals>                         <phase>test</phase>                         <goals>                        <configuration>                             <goal>test</goal>                            <skip>false</skip>                         </goals>                            <includes>                         <configuration>                             <skip>false</skip>                                <include>**/When*.*</include>                             <includes>                            </includes>                                 <include>**/When*.*</include>                            <excludes>                             </includes>                             <excludes>                                <exclude>%regex[.*integration.*When.*]</exclude>                                 <exclude>%regex[.*integration.*When.*]</exclude>                            </excludes>                             </excludes>                         </configuration>                        </configuration>                     </execution>                    </execution>                     <execution>                         <id>integration-tests</id> Excluding integration tests from the test phase                         <phase>integration-test</phase>                         <goals>                             <goal>test</goal>                         </goals>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>%regex[.*integration.*]</include>                             </includes>                         </configuration>                     </execution> Using package conventions                 </executions>             </plugin>
    • Split unit and integration tests            <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId>maven-surefire-plugin</artifactId>                 <version>2.11</version>                 <configuration>                     <skip>true</skip>                 </configuration>                 <executions>                     <execution>                         <id>unit-tests</id>Run only integration tests in the integration-test phase                         <phase>test</phase>                         <goals>                             <goal>test</goal>                         </goals>                     <execution>                         <configuration>                         <id>integration-tests</id>                             <skip>false</skip>                             <includes>                         <phase>integration-test</phase>                                 <include>**/When*.*</include>                         <goals>                             </includes>                             <goal>test</goal>                             <excludes>                                 <exclude>%regex[.*integration.*When.*]</exclude>                         </goals>                             </excludes>                         <configuration>                         </configuration>                             <skip>false</skip>                     </execution>                     <execution>                             <includes>                         <id>integration-tests</id>                                 <include>%regex[.*integration.*]</include>                         <phase>integration-test</phase>                         <goals>                             </includes>                             <goal>test</goal>                         </configuration>                         </goals>                     </execution>                         <configuration>                             <skip>false</skip>                             <includes>                                 <include>%regex[.*integration.*]</include>                             </includes>                         </configuration>                     </execution> Using package conventions                 </executions>             </plugin>
    • CompileDefault build Unit Test mvn deploy Package Integration Test
    • CompileDefault build Unit Test mvn install Package Integration Test Jenkins Artifactory Plugin
    • CompileDefault build Unit Test mvn install Package Integration Test mvn deploy:deploy
    • Eliminate waste
    • Run code coverage with the integration tests compile test-compile Integration tests mvn verify test package integration-test verify Test coverage mvn cobertura compile test-compile Duplication! test package integration-test cobertura Creates its own instrumented JAR files
    • JACOCOJava Code Coverage Code coverage on the flyDoesn’t mess with your JAR files
    • Run code coverage with the integration tests<plugin>    <groupId>org.jacoco</groupId>    <artifactId>jacoco-maven-plugin</artifactId>    <version>0.5.10.201208310627</version>    <executions>        <execution>            <id>jacoco-initialize</id>            <goals>                <goal>prepare-agent</goal>            </goals> Measure code coverage        </execution> after the integration tests        <execution>            <id>jacoco-site</id>            <phase>post-integration-test</phase>            <goals>                <goal>report</goal>            </goals>        </execution>    </executions></plugin>
    •            <plugin>Run code coverage with the integration tests                <groupId>org.jacoco</groupId>                <artifactId>jacoco-­‐maven-­‐plugin</artifactId>                <executions>                    <execution>                        <goals>                            <goal>prepare-­‐agent</goal>                        </goals>                    </execution>                    <execution>                        <id>check</id>                        <goals>                            <goal>check</goal> Define minimum coverage                        </goals>                        <phase>post-­‐integration-­‐test</phase>                        <configuration>                            <check>                                <classRate>95</classRate>                                <instructionRate>95</instructionRate>                                <methodRate>90</methodRate>                                <branchRate>95</branchRate>                                <complexityRate>95</complexityRate>                                <lineRate>95</lineRate>                            </check>                        </configuration>                    </execution>
    • Run code coverage with the integration testsIntegration tests/test compile test-compile mvn install test coverage package integration-test verify Uninstrumented JAR Coverage checks and report
    • Minimal overheadBuild Time Normal build With JaCoCo
    • Reuse binaries wherever possible Default build 1.0.203Deploy to TESTAcceptance Tests 1.0.201 1.0.202 1.0.203Deploy to UAT
    • Have a separate acceptance test suite Acceptance Tests TEST UAT PROD
    • Take code quality seriously Checkstyle Findbugs
    • Take code quality seriouslyCode quality metrics mvn site
    • Take code quality seriously Pick and choose your metricsCode quality metrics mvn pmd:check mvn findbugs:check mvn checkstye:checkstyle Fail the build if there are violations
    • Avoid the Maven Release PluginDon’t sweat the version numbers
    • Developers always work on a SNAPSHOT version 1.0-SNAPSHOT This number is pretty arbitrary
    • Jenkins sets a release candidate version at the start of the build pipeline 1.0-SNAPSHOT 1.0.203 This number is a build counter
    • This version goes through the build pipeline 1.0.203 Unit tests Acceptance tests Code quality metrics Deploy to TEST
    • This version goes through the build pipeline 1.0.203 1.0.204 1.0.205 Unit tests Acceptance tests Code quality metrics Deploy to TEST Acceptance Tests 1.0.203 1.0.204 1.0.205
    • Create a new release branch Update the version number Build and test release candidate Did it work? No YesDrop release branch Push release branchNotify everyone Deploy release candidate
    • Create a new release branch Update the version number Build and test release candidate 1.0.203 Did it work? No YesDrop release branch Push release branchNotify everyone Deploy release candidate
    • Create a new release branch Update the version number Versions Plugin Build and test release candidate mvn versions:set -DnewVersion=1.0.203 Did it work? No YesDrop release branch Push release branchNotify everyone Deploy release candidate
    • Create a new release branch Update the version number Build and test release candidate Did mvn verify ... it work? No YesDrop release branch Push release branchNotify everyone Deploy release candidate
    • And make it visible The Build Pipeline plugin
    • Let’s see it in action! TEST UAT PROD Jenkins
    • Let’s see it in action!
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod
    • initial-build Links to binary artifacts in ArtifactoryRelease candidate number
    • initial-buildLinks to binary artifacts in Artifactory
    • initial-build Use a parameterized build to configure the major build version Users can override the default major version
    • initial-build Create a new branchUpdate the version in the pom files Build the binaries
    • initial-build Conditional build step plugin If the build succeeds... Commit the changes and push the branch to the repository
    • initial-build If the build fails... Delete the branch
    • initial-buildDeploy the release candidate to Artifactory
    • initial-build Deploy to the test environment Target platform
    • initial-build<plugin> <groupId>com.jelastic</groupId> <artifactId>jelastic-maven-plugin</artifactId> <version>1.6</version> <configuration> <email>${jelastic.username}</email> <password>${jelastic.password}</password> <context>${jelastic.context}</context> <environment>${jelastic.environment}</environment> <api_hoster>app.jelastic.servint.net</api_hoster> </configuration></plugin>
    • initial-build Archive binaryUpdate the build description
    • initial-build Archive binaryPass the release branch to the next build job
    • initial-buildDon’t start a new build pipeline ifone is currently running.
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod
    • initial-build code-qualityPass in the release we want to build against deploy-to-test acceptance-tests deploy-to-uat acceptance-tests deploy-to-prod
    • initial-build code-quality deploy-to-testBuild from the release candidate branch acceptance-tests deploy-to-uat acceptance-tests deploy-to-prod
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod
    • initial-build code-qualityCopy the WAR file from the initial build deploy-to-test acceptance-tests deploy-to-uat acceptance-tests deploy-to-prod
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat ...deploy this WAR file acceptance-testsdeploy-to-prod
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod the acceptance tests ...and run
    • initial-build code-quality deploy-to-test acceptance-tests deploy-to-uatWhat platform do we run the acceptance test against acceptance-tests deploy-to-prod
    • initial-build code-quality deploy-to-test acceptance-tests deploy-to-uatWhat platform do we run the acceptance test against acceptance-tests deploy-to-prod
    • initial-build code-qualitydeploy-to-test acceptance-testsdeploy-to-uat acceptance-testsdeploy-to-prod
    • initial-build code-quality deploy-to-test acceptance-tests deploy-to-uatWhat platform do we run the acceptance test against acceptance-tests deploy-to-prod
    • initial-build code-quality deploy-to-test acceptance-tests deploy-to-uatWhat platform do we run the acceptance test against acceptance-tests deploy-to-prod
    • initial-build code-quality deploy-to-test acceptance-tests deploy-to-uatBuild promotion status acceptance-tests deploy-to-prod
    • initial-buildCopy the WAR file from the initial build... code-quality deploy-to-test acceptance-tests deploy-to-uat ...and deploy it to UAT acceptance-tests deploy-to-prod
    • A build promotioninitial-build deploy to production process to code-quality deploy-to-test acceptance-tests deploy-to-uat acceptance-tests deploy-to-prod
    • A build promotioninitial-build deploy to production process to code-quality deploy-to-test acceptance-tests deploy-to-uat acceptance-tests deploy-to-prod
    • Build pipeline for an overview of the process
    • Thank You John  Ferguson  Smart Email:  john.smart@wakaleo.com Web:  hHp://www.wakaleo.com TwiHer:  wakaleo