git version at runtime and packaging

Jackie
Jan 13, 2022

--

I was not able to generate the git.properties at the beginning. somehow turns out it was due to a missing version for the plugin.

<plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <version>4.0.5</version> <!--need to add the specific version--> <executions> <execution> <goals> <goal>revision</goal> </goals> </execution> </executions> </plugin>

with that, at packaging, it could generate the package with the SHA.

<version>1.0-${git.commit.id.abbrev}-SNAPSHOT</version>

the package name like ABC-1.0-7X7X40a-SNAPSHOT.jar

at runtime, with spring actuator enabled, it could auto pick up the commit info:

Published

Originally published at https://lwpro2.dev on January 13, 2022.

--

--