1

I am trouble with generating build number using maven plugin, I have the plugin configuration in pom file like

<plugin>
                <groupId>ru.concerteza.buildnumber</groupId>
                <artifactId>maven-jgit-buildnumber-plugin</artifactId>
                <version>1.2.7</version>
                <executions>
                    <execution>
                        <id>git-buildnumber</id>
                        <goals>
                            <goal>extract-buildnumber</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <javaScriptBuildnumberCallback>
                                tag + "_" + branch + "_" +shortRevision + "_" + commitsCount
                            </javaScriptBuildnumberCallback>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

So, my problem is I want to print timestamp with build number , Can anyone tell me how can I print timestamp with the build number ?

snehal
  • 1,798
  • 4
  • 17
  • 24

2 Answers2

2

Depending on your maven version, either use the maven.build.timestamp property or the maven-timestamp-plugin.

<plugins>
  <plugin>
   <groupId>com.keyboardsamurais.maven</groupId>
   <artifactId>maven-timestamp-plugin</artifactId>
   <version>1.0</version>
   <configuration>
    <propertyName>timestamp</propertyName>
    <timestampPattern>dd.MM.yyyy HH:mm</timestampPattern>
   </configuration>
   <executions>
    <execution>
     <goals>
      <goal>create</goal>
     </goals>
    </execution>
   </executions>
  </plugin>

...

<javaScriptBuildnumberCallback>
  tag + "_" + branch + "_" +shortRevision + "_" + commitsCount + "_" + ${timestamp}
</javaScriptBuildnumberCallback>
Morfic
  • 15,178
  • 3
  • 51
  • 61
0

I added new properties, including buildDate, to that plugin. Also, you can specify which TimeZone should be used, e.g. system default time zone or some specific one (as opposed to Maven timestamp which is always returned in UTC). See https://github.com/elab/jgit-buildnumber (plugin is released to Maven Central as well).

Eugen Labun
  • 2,561
  • 1
  • 22
  • 18