Minimal Jenkinsfile for a Gradle Build

Published:
Tags:
Gradle Java Jenkins Spring Boot

Starting work on a new project for a client, and their devops organization is off working on some new framework for CI/CD deploys. So in the meantime we just need a super minimal Jenkins build. 

The requirements I have for this are:

  1. Run the build 
  2. Run the tests 
  3. Display test report 
  4. Execute on every push to git, including PR branches 
  5. Email failures 

With that in mind, here is a quite minimal Jenkins script for our gradle build:

I'm not 100% sure if that last email block is needed, but it worked and I don't feel like messing with it. 

Also our builds are running against BitBucket using a Jenkins plugin, and even though we have it setup without needing polling, we still needed that Bitbucket poll hack. So here you go!