Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

When reporting a build to Sealights via Maven from the command line, you need to provide a different build name each time you create a new Build Session ID.

Sample of JSON configuration file
Code Block
title
languagexmlSample of JSON configuration file
{
  ...
  "buildName": "${BUILD_NUMBER}",
  ...
}

Instead of updating manually your pom.xml or the JSON configuration file, you have several ways to dynamically update the Build Name parameter passed to Sealights.

Solutions

...

Maven Parameter from Command line to Sealights plugin

...

Using an timestamp generated by Sealights

Sealights Java agents supports a specific SL_Timestamp variable the JSON the JSON configuration file to set the Sealights Maven plugin generating automatically a time stamp as a default buildname.
The default format is yyyy.MM.dd-hh.mm.

Sample of JSON configuration file
Code Block
title
languagexmlSample of JSON configuration file
{
  ...
  "buildName": "SL_Timestamp",
  ...
}

Using a timestamp variable in pom.xml

Maven provides a built-in property called $called ${maven.build.timestamp} that provides the time the build was initiated and this can be used in your Sealights profile after wrapping in another property

...

Pom.xml with timestamp
linenumbers
Code Block
languagetruexml
<properties>
    ...
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyyMMdd_HHmm</maven.build.timestamp.format>
</properties>

From now on, you can use this property ${timestamp} either in the Sealights profile directly in the pom.xml or inside the JSON configuration file.

Sample of JSON configuration file
code
Code Block
languagexmltitleSample of JSON configuration file
{
  ...
  "buildName": "${timestamp}",
  ...
}
languagexml
title
Sample of profile using timestamp property
Code Block
languagexml
<configuration>
	...
	<buildSessionIdFile>buildSessionId.txt</buildSessionIdFile>
	<createBuildSessionId>true</createBuildSessionId>
	<appName>MyApp</appName>
	<branchName>master</branchName>
	<buildName>${timestamp}</buildName>
	...
</configuration>

...