> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/maven/pass-build-name-from-cli.md).

# Pass Build Name from CLI

### Problem <a href="#problem" id="problem"></a>

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 overflow="wrap" lineNumbers="true" %}

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

{% endcode %}

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 <a href="#solutions" id="solutions"></a>

#### Maven Parameter from Command line to Sealights plugin <a href="#maven-parameter-from-command-line-to-sealights-plugin" id="maven-parameter-from-command-line-to-sealights-plugin"></a>

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

{% code overflow="wrap" lineNumbers="true" %}

```
mvn clean install -Psealights -DBUILD_NUMBER=3
```

{% endcode %}

**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

{% code overflow="wrap" lineNumbers="true" %}

```bash
mvn clean install -Psealights -DBUILD_NUMBER=`date +"%y%m%d_%H%M"`
```

{% endcode %}

#### Timestamp defined as part of the Maven configuration <a href="#timestamp-defined-as-part-of-the-maven-configuration" id="timestamp-defined-as-part-of-the-maven-configuration"></a>

**Using an timestamp generated by Sealights**

Sealights Java agents supports a specific SL\_Timestamp variable 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 overflow="wrap" lineNumbers="true" %}

```
{
  ...
  "buildName": "SL_Timestamp",
  ...
}
```

{% endcode %}

**Using a timestamp variable in pom.xml**

Maven provides a built-in property 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**

{% code overflow="wrap" lineNumbers="true" %}

```xml
<properties>
    ...
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyyMMdd_HHmm</maven.build.timestamp.format>
</properties>
```

{% endcode %}

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**

```
{
  ...
  "buildName": "${timestamp}",
  ...
}
```

**Sample of profile using timestamp property**

```xml
<configuration>
	...
	<buildSessionIdFile>buildSessionId.txt</buildSessionIdFile>
	<createBuildSessionId>true</createBuildSessionId>
	<appName>MyApp</appName>
	<branchName>master</branchName>
	<buildName>${timestamp}</buildName>
	...
</configuration>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/maven/pass-build-name-from-cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
