We're using the Maven plugin git-commit-id-maven-plugin and want to make both hash and dirty status available to our build. Our plugin:
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
E.g. we have a filtered properties file with:
git=${git.commit.id.describe}
However this describe-variant cares about tags, which we do not want into our usage of it. If doing this from terminal I see from other questions and answers that this is easily done.
E.g. ${git.commit.id.describe} might return:
mytag-hash-dirty
Our ideal result would be only:
hash-dirty
How can I achieve the "hash and dirty status"-only result using the git-commit-id-maven-plugin with Maven?
I ended up using the following configuration of the plugin:
Where we only include/consider tags that match the
!*pattern. This works in tandem withalwaysbeingtrue(which happens to be the default). This should be fairly equivalent to the following command:This gives the desired result when using the
${git.commit.id.describe}variable.