Using Java Agents - Generating a session ID

Before running the build scan and tests, you need to create a session ID. The session ID is provided for each step to link them together as one complete cycle.

 

Generating a session ID in Java

Generating a session ID in Java is done using the Java Build scanner with the -config flag and requires to specify a comma-separated list of packages composing the application.

java -jar sl-build-scanner.jar -config -tokenfile /path/to/sltoken.txt -appname "myApp" -branchname "master" -buildname "1" -pi "*com.company.*"

See 'Java Command Reference - Creating a session ID' for full parameter details

If you don’t know the list of packages of the application, please refer to our dedicated command described in a detailed documentation page.

The buildname parameter above should reflect a meaningful versioning of your service or application.
In some cases, you can use timestamps as well, via commands like `date +"%y%m%d_%H%M"` (Linux) or $(Get-Date -Format "yyyyMMdd_HHmm") (Powershell)

Using the session ID

The session ID will be printed to the console output and a file called 'buildSessionId.txt' will be generated containing it.

The file can be used as is in the different agents parameters or can be used to fill in an environment parameter to be in a command line.

Unix: export SL_BUILD_SESSION_ID=`cat buildSessionId.txt` Windows: set /p SL_BUILD_SESSION_ID=<buildSessionId.txt