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.

Code Block
languagexml
titleSample 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

When using a variable in the Maven configuration (JSON or pom.xml), you can override its value via -D flag in the command line

...

...

{
  ...
  "buildName": "${BUILD_NUMBER}",
  ...
}


you'll have to initiate the build via a command similar to 

Code Block
languagebash
mvn clean install -Psealights -DBUILD_NUMBER=3

Using a timestamp variable from the command line

In order to use a timestamp to report the build to Sealights, please prefer to use for example -DBUILD_NUMBER=`date +"%y%m%d_%H%M"`

Using a timestamp variable in pom.xml

for Maven versions prior to 3.0.0, you need to wrap the build timestamp in another property

Code Block
languagexml
titlePom.xml with timestamp
linenumberstrue
<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.

Code Block
languagexml

...

titleSample of JSON configuration file
{
  ...
  "buildName": "${timestamp}",
  ...
}


Code Block
languagexml
titleSample of profile using timestamp property
<configuration>
	...
	<buildSessionIdFile>buildSessionId.txt</buildSessionIdFile>
	<createBuildSessionId>true</createBuildSessionId>
	<appName>MyApp</appName>
	<branchName>master</branchName>
	<buildName>${timestamp}</buildName>
	...
</configuration>