Maven Legacy - Defining a Sealights profile in the pom.xml file
Add -Psealights maven targets in the jenkins build step
Configuring Maven plugin in the pom.xml file
You can create the configuration in a profile or directly in the main settings
In the plugins section add a plugin with the following parameters:
- groupId - set to io.sealights.on-premise.agents.plugin
- artifactId - set to sealights-maven-plugin
- version - set to 4.0.991
- configuration section with the following parameters
- token or tokenFile - set with a token or a file containing the token obtained from the SeaLights dashboard
- buildSessionId or buildSessionIdFile - Set with a build session id or a file containing the build session id created by the config step
- createBuildSessionId - Set to false
- testStage - Set the name of the test stage as will be displayed on the SeaLights dashboard
- workspacepath - Set to with the path to the binary files to scan (Different per module). For example ${project.build.outputDirectory}
Note: there are rare cases that this needs to be changed. Make sure you really need to change it before doing so. - filesincluded - Set to the binary files to scan. for example *.class
- filesexcluded - Set to the binary files to excluded from the scan. for example *test-classes*
- filesStorage - Set to the temp folder for the agent to create temporary files in. For example /tmp
- logEnabled - Set to true if you want a log to be created
- logLevel - Set the log level to create. For example INFO
- metadata section with CI details
- jobName - Set to the name of the build job. For example ${JOB_NAME}
- logsUrl - Set to the link that the SeaLights dashboard should provide to view the build log. For example ${BUILD_URL}/console
- sealightsJvmParams - Entry to provide JVM params to the SeaLights agent
- includeResources - Set to include the token and build session ID files in the built resources
- executions section following executions
- If you want to scan a build add an execution with the goal set to build-scanner
- If you want to monitor the test information add an execution with the goal set to test-listener
If you override the surefire <argLine>...</argLine> then you need to add the SeaLights parameters inside the override value. See Surefire integration
See 'Java Command Reference - Installing test listener as Java Agent' for more parameter values and information
<profiles> <profile> <id>sealights</id> <build> <plugins> <plugin> <groupId>io.sealights.on-premise.agents.plugin</groupId> <artifactId>sealights-maven-plugin</artifactId> <version>4.0.991</version> <configuration> <!-- <token>${SL_TOKEN}</token> --> <tokenFile>/path/to/sltoken.txt</tokenFile> <!-- <buildSessionId>${SL_BUILD_SESSION_ID}</buildSessionId> --> <buildSessionIdFile>buildSessionId.txt</buildSessionIdFile> <createBuildSessionId>false</createBuildSessionId> <testStage>Unit Tests</testStage> <filesincluded>*.class</filesincluded> <filesStorage>/tmp</filesStorage> <filesexcluded>*test-classes*</filesexcluded> <logEnabled>false</logEnabled> <logLevel>WARN</logLevel> <sealightsJvmParams></sealightsJvmParams> <includeResources>true</includeResources> <metadata> <jobName>${JOB_NAME}</jobName> <logsUrl>${BUILD_URL}/console</logsUrl> </metadata> <!-- <proxy>http://your.proxy:1234/proxy> --> </configuration> <executions> <execution> <id>a1</id> <goals> <goal>build-scanner</goal> </goals> </execution> <execution> <id>a2</id> <goals> <goal>test-listener</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
Creating a buildSessionId
Instead of creating the build session ID externally, you can create it directly in the pom
To do so, you add the following entries in the configuration section:
- appName - Name of the application as you want to see it on the SeaLights dashboard
- branch - Name of the branch as you want to see it on the SeaLights dashboard
- build - Name of the build as you want to see it on the SeaLights dashboard
- packagesincluded - Comma-separated list of packages to include in scan
<configuration> <createBuildSessionId>true</createBuildSessionId> <appName>${JOB_NAME}</appName> <branch>${GIT_BRANCH}</branch> <build>${BUILD_NUMBER}</build> <packagesincluded>*com.example.*</packagesincluded> <!-- <packagesexcluded></packagesexcluded> --> </configuration>
Configuring SCM
SeaLights by default provides all links to the SCM for Github.
You can configure SeaLights to prepare the links for Bitbucket and Gitlab as well with the following parameters placed under the sealightsJvmParams section:
- sl.scm.provider - set to github, Bitbucket or gitlab
- sl.scm.baseUrl - When working with an on-premise installation of your SCM and access from the build machine is diffrent than the one accessed by the users, then you can provide the base URL to use
See SCM Links - Links created by Sealights do not point back to the correct SCM page for more details - version - set to the version of the on-premise version you use
<sealightsJvmParams> <sl.scm.provider>bitbucket</sl.scm.provider> <sl.scm.baseUrl>https://my.bitbucket.com/projects/ABCD/repos/XYZ/browse/A1</sl.scm.baseUrl> <sl.scm.version>4.6</sl.scm.version> </sealightsJvmParams>
Pre-downloading the agents
The Maven plugin downloads the recommended agent at the beginning of the run. If you want to pre-download them and provide them to the plugin, you can do so with the flags buildScannerJar & testListenerJar.
<buildScannerJar>./sl-build-scanner.jar</buildScannerJar> <testListenerJar>./sl-test-listener.jar</testListenerJar>
The agents used here should be downloaded either with the latest agent or the recommended one as stated in Downloading the java agent files
Tagging
You can add tags to be viewed in the cockpit for the agents started by this maven job by passing them through the sl.tags property in the sealightsJvmParams field
<sealightsJvmParams> <sl.tags>mytag</sl.tags> </sealightsJvmParams>