Jenkins pipeline for continuous delivery and deployment

before we show how we can apply continuous delivery and deployment using Jenkins pipeline as a code , we need to refresh our mind about the difference between continuous integration vs delivery vs deployment as being show below :

Screen Shot 2017-12-03 at 15.12.06.png

What about releasing process and versioning in continuous delivery  :

basically i am not big fan of maven release plugin for some reasons :

Let’s consider the principles of Continuous Delivery.

  • “Every build is a potential release”
  • “Team need to eliminate manual bottlenecks”
  • “Team need to automate wherever possible”

Current drawbacks and limitations of maven release way :

  • Overhead. The maven-release plugin runs 3 (!) full build and test cycles, manipulates the POM 2 times and creates 3 Git revisions.
  • Not isolated. The plugin can easily get in a mess when someone else commits changes during the release build.
  • Not atomic. If something went wrong in the last step (e.g. during the artifact upload), we are facing an invalid state. We have to clean up the created Git tag, Git revisions and fix the wrong version in the pom manually.

So let us simplify the versioning process in an efficient way within out continuous delivery model :

  • checking out the software as it is
  • building, testing and packaging it
  • giving it a version so it can be uniquely identified and tractable (release step)


  • deploying it to an artifact repository where it can then be picked for actual roll out on target machines
  • tagging this state in SCM so it can be associated with the matching artifact

Which leads to :

  • Every artifact is potentially shippable. So there is no need for a dedicated release workflow anymore!
    • The delivery pipeline is significantly simplified and automated
    • Traceable. It’s obvious, which commits are included.

Screen Shot 2017-12-03 at 15.35.41

So how we can implement continuous delivery and a conditional continuous deployment using Jenkins pipeline , off-course you can add more stages  based into team process like for example performance test, just added till acceptance as production will be just the same :

we will use Jenkins pipeline as a code as it give more power to the team to control they delivery process:

  1. when a Git commit is triggered to development branch , it will trigger Jenkins pipeline to checkout the code , build it , unit test it and if all is green it will trigger the integration test plus sonar check for your code quality gate
  2. if all green , deploy to development server using the created package from Jenkins work space or Nexus Snapshots if you prefer
  3. then if there is a release candidate which means a merge request to your master branch , the it will do the same steps as above plus creating the release candidate using the release versioning explained above.
  4. Push the released artifact to Nexus and do acceptance deployment and auto acceptance functional testing
  5. Then prompt to production and if it is approved it will be deployed into production
  6. Off-course deployment task must be automated if you need continuous deployment using an automation tools like Ansible or other options.

Now let us explain how it will be done via Jenkins Pipeline code as the following :

then you can use it by creating multi branch project in Jenkins and mark it to get use Jenkins pipeline as a code

References :

  1. Jenkins pipeline :
  2. Jenkins file with a sample app for testing the pipeline execution on GitHub:

How to write a spring boot web maven archetype with common practices in place

Here I am sharing a custom spring boot web maven archetype I have created to encapsulate all the common practices as an example how you can do the same in your team for common standards that could be imposed by your company or your team.


the Maven archetype for Spring Boot web application which has all common standards on place ready for development

  • Java 1.8+
  • Maven 3.3+
  • Spring boot 1.5.6+
  • Lombok abstraction
  • JPA with H2 for explanation
  • Swagger 2 API documentation
  • Spring retry and circuit breaker for external service call
  • REST API model validation
  • Spring cloud config for external configuration on GIT repository
  • Cucumber and Spring Boot test for integration test
  • Jenkins Pipeline for multi branch project
  • continuous delivery and integration standards with Sonar check and release management
  • Support retry in sanity checks
  • Logback configuration


To install the archetype in your local repository execute following commands:

$ git clone
$ cd spring-boot-quickstart-archtype
$ mvn clean install

Create a project

$ mvn archetype:generate \
     -DarchetypeGroupId=com.romeh.spring-boot-archetypes \
     -DarchetypeArtifactId=spring-boot-quickstart \
     -DarchetypeVersion=1.0.0 \
     -DgroupId=com.test \
     -DartifactId=sampleapp \
     -Dversion=1.0.0-SNAPSHOT \

Test the generated app rest API via SWAGGER


Sample app generated from that archetype can be found here :


References :