git version at runtime and packaging

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:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s