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:

  1. groupId - set to io.sealights.on-premise.agents.plugin
  2. artifactId - set to sealights-maven-plugin
  3. version - set to 4.0.991
  4. configuration section with the following parameters
    1. token or tokenFile - set with a token or a file containing the token obtained from the SeaLights dashboard
    2. buildSessionId or buildSessionIdFile - Set with a build session id or a file containing the build session id created by the config step
    3. createBuildSessionId - Set to false
    4. testStage - Set the name of the test stage as will be displayed on the SeaLights dashboard
    5. workspacepathSet 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.
    6. filesincluded - Set to the binary files to scan. for example  *.class
    7. filesexcluded - Set to the binary files to excluded from the scan. for example *test-classes*
    8. filesStorage - Set to the temp folder for the agent to create temporary files in. For example /tmp
    9. logEnabled - Set to true if you want a log to be created
    10. logLevel - Set the log level to create. For example INFO
    11. metadata section with CI details
      1. jobName - Set to the name of the build job. For example ${JOB_NAME}
      2. logsUrl - Set to the link that the SeaLights dashboard should provide to view the build log. For example ${BUILD_URL}/console
    12. sealightsJvmParams - Entry to provide JVM params to the SeaLights agent
    13. includeResources - Set to include the token and build session ID files in the built resources
  5. executions section following executions
    1. If you want to scan a build add an execution with the goal set to build-scanner
    2. 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

Sample of 'sealights' profile
<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
  • packagesincludedComma-separated list of packages to include in scan
Sample of buildSessionId configuration
<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
Sample of SCM configuration - POM.xml
<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>