Add git-commit-id-maven-plugin to generate build metadat 69/141069/1
authorsourabh_sourabh <sourabh.sourabh@est.tech>
Tue, 3 Jun 2025 13:03:05 +0000 (14:03 +0100)
committersourabh_sourabh <sourabh.sourabh@est.tech>
Tue, 3 Jun 2025 13:03:05 +0000 (14:03 +0100)
- Integrated git-commit-id-maven-plugin in pom.xml
- Configured it to run during the package phase
- Outputs selected metadata to git.properties.
- Set custom date format and file output location

Issue-ID: CPS-2690
Change-Id: Id496bd7cc67982dedfd0a70dbdb6136046a2dac1
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
dmi-service/pom.xml
dmi-service/src/main/resources/application.yml
dmi-stub/dmi-stub-service/src/main/resources/application.yml
dmi-stub/pom.xml
pom.xml

index 830ff98..56ff654 100644 (file)
                 <artifactId>maven-deploy-plugin</artifactId>
                 <version>${maven.deploy.plugin.version}</version>
             </plugin>
+            <plugin>
+                <groupId>io.github.git-commit-id</groupId>
+                <artifactId>git-commit-id-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>get-git-info</id>
+                        <goals>
+                            <goal>revision</goal>
+                        </goals>
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+                <configuration>
+                    <dateFormat>yyyy-MM-dd'T'HH:mm:ss.sss'Z'</dateFormat>
+                    <includeOnlyProperties>
+                        <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
+                        <includeOnlyProperty>^git.commit.(id.full|message.short|user.name|user.email)$</includeOnlyProperty>
+                        <includeOnlyProperty>^git.branch</includeOnlyProperty>
+                    </includeOnlyProperties>
+                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
+                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
+                    <commitIdGenerationMode>full</commitIdGenerationMode>
+                </configuration>
+            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>
index 003aa19..ef61a08 100644 (file)
@@ -94,6 +94,10 @@ management:
         enabled: true
     loggers:
       enabled: true
+  info:
+    git:
+      enabled: true
+      mode: full
 
 cps-core:
   baseUrl: http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
index 09edb13..38f35ac 100644 (file)
@@ -40,13 +40,17 @@ management:
     endpoints:
         web:
             exposure:
-                include: health
+                include: info,health
     endpoint:
         health:
             show-details: always
             # kubernetes probes: liveness and readiness
             probes:
                 enabled: true
+    info:
+        git:
+            enabled: true
+            mode: full
 
 app:
     ncmp:
index dedcc3e..ce6fd1e 100644 (file)
             </execution>
         </executions>
     </plugin>
+        <plugin>
+            <groupId>io.github.git-commit-id</groupId>
+            <artifactId>git-commit-id-maven-plugin</artifactId>
+            <executions>
+                <execution>
+                    <id>get-git-info</id>
+                    <goals>
+                        <goal>revision</goal>
+                    </goals>
+                    <phase>package</phase>
+                </execution>
+            </executions>
+            <configuration>
+                <dateFormat>yyyy-MM-dd'T'HH:mm:ss.sss'Z'</dateFormat>
+                <includeOnlyProperties>
+                    <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
+                    <includeOnlyProperty>^git.commit.(id.full|message.short|user.name|user.email)$</includeOnlyProperty>
+                    <includeOnlyProperty>^git.branch</includeOnlyProperty>
+                </includeOnlyProperties>
+                <generateGitPropertiesFile>true</generateGitPropertiesFile>
+                <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
+                <commitIdGenerationMode>full</commitIdGenerationMode>
+            </configuration>
+        </plugin>
     </plugins>
     </build>
 </project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index fb3b78c..1f56532 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                 <artifactId>maven-deploy-plugin</artifactId>
                 <version>${maven.deploy.plugin.version}</version>
             </plugin>
+            <plugin>
+                <groupId>io.github.git-commit-id</groupId>
+                <artifactId>git-commit-id-maven-plugin</artifactId>
+                <version>9.0.1</version>
+                <executions>
+                    <execution>
+                        <id>get-git-info</id>
+                        <goals>
+                            <goal>revision</goal>
+                        </goals>
+                        <phase>package</phase>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>