Skip to content

Gradle plugin to generate build information that can be consumed by Spring Boot Actuator Info

License

Notifications You must be signed in to change notification settings

spasam/spring-boot-build-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Info generator Gradle plugin for Spring Boot Actuator

This gradle plugin generates properties file(s) that can be consumed by Spring Boot Actuator Info endpoint


Plugin Build Status

Prerequisites

Java and Spring Boot gradle plugins are expected to be present in build.gradle. Example:

plugins {
  ...
  id 'java'
  id 'org.springframework.boot' version '2.1.3.RELEASE'
  ...
}

Usage

Add the following in your build.gradle plugins section:

plugins {
  ...
  id 'com.pasam.gradle.buildinfo' version '0.1.3'
  ...
}

Properties

This gradle plugin depends on gradle-git-properties plugin version 2.0.0. There is no explicit need to depend on gradle-git-properties in your project. git.properties generated by gradle-git-properties contains extensive information about the state of SCM at the time of the build. See output below.

This gradle plugin generates build-info.properties that includes the following information:

Project specific properties from build.gradle

  • artifact
  • name
  • group
  • version
  • time (build date/time)
  • source-compatibility
  • target-compatibility

JVM system properties:

  • user.name
  • java.vendor
  • java.version
  • os.arch
  • os.name
  • os.version

Environment variables:

  • BUILD_URL (only if set. Useful when running builds on Jenkins)

Runtime dependencies (jars)

Output

During the build, git.properties will be generated in build resources directory. git.properties should look like:

git.branch=master
git.build.host=my-host
git.build.time=2019-03-17T18\:25\:23-0400
git.build.user.email[email protected]
git.build.user.name=Seshu Pasam
git.build.version=unspecified
git.closest.tag.commit.count=
git.closest.tag.name=
git.commit.id=2f4f4f52af30ea10d4dbfe0489aad924a0a86009
git.commit.id.abbrev=2f4f4f5
git.commit.id.describe=
git.commit.message.full=Commit message full
git.commit.message.short=Commit message short
git.commit.time=2019-03-13T11\:45\:48-0400
git.commit.user.email[email protected]
git.commit.user.name=Seshu Pasam
git.dirty=true
git.remote.origin.url[email protected]\:spasam/spring-boot-build-info
git.tags=1.29.0
git.total.commit.count=25

build-info.properties file will also be generated in build resources META-INF directory. Contents of this properties file should look like:

build.artifact = spring-boot-build-info
build.name = spring-boot-build-info
build.group = com.pasam
build.version = 0.1.2
build.time = 2019-03-17T22:42:50.131910Z
build.source-compatibility = 11
build.target-compatibility = 11
build.user-name = spasam
build.java-vendor = Oracle Corporation
build.java-version = 11.0.1
build.os-arch = x86_64
build.os-name = Mac OS X
build.os-version = 10.14.3
build.dependencies.spring-boot = 2.1.3.RELEASE
build.dependencies.activation = 1.1
...

With Spring Boot actuator enabled, actuator should serve up git and build-info properties as JSON. Accessing <host>:<mgmg-port>/<actuator-info-endpoint> should dump JSON similar to:

{
  "git": {
    "branch": "master",
    "build": {
      "time": "2019-03-17T23:29:20Z",
      "version": "0.1.2",
      "user": {
        "name": "Seshu Pasam",
        "email": "[email protected]"
      },
      "host": "my-host"
    },
    "commit": {
      "time": "2019-03-15T22:32:25Z",
      "message": {
        "full": "Commit message full",
        "short": "Commit message fshort"
      },
      "id": {
        "describe": "",
        "abbrev": "14b1431",
        "full": "14b1431cfee81908c1ca70bda79b9e28625cfbd2"
      },
      "user": {
        "email": "[email protected]",
        "name": "Seshu Pasam"
      }
    },
    "dirty": "true",
    "tags": "1.30.0-rc6,1.30.0-rc7",
    "total": {
      "commit": {
        "count": "28"
      }
    },
    "closest": {
      "tag": {
        "commit": {
          "count": ""
        },
        "name": ""
      }
    },
    "remote": {
      "origin": {
        "url": "[email protected]:spasam/spring-boot-build-info"
      }
    }
  },
  "build": {
    "dependencies": {
      "spring-boot": "2.1.3.RELEASE",
      "activation": "1.1"
    },
    "os-arch": "x86_64",
    "version": "0.1.2",
    "user-name": "spasam",
    "os-name": "Mac OS X",
    "source-compatibility": "11",
    "java-vendor": "Oracle Corporation",
    "name": "spring-boot-build-info",
    "time": "2019-03-17T23:29:19.531Z",
    "artifact": "spring-boot-build-info",
    "group": "com.pasam",
    "java-version": "11.0.1",
    "target-compatibility": "11",
    "os-version": "10.14.3"
  }
}

About

Gradle plugin to generate build information that can be consumed by Spring Boot Actuator Info

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages