Table of Contents | ||||
---|---|---|---|---|
|
Integrating the SeaLights Maven plugin into your pom.xml
You can use the SeaLights agent to update your maven pom.xml with the needed changes to run your Maven build using the Jenkins Maven Plugin
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Configuration file
JSON configuration parameters reference
Create a JSON configuration file with the following parameters to provide the necessary configuration fields to the SeaLights Maven plugin:
...
Note |
---|
|
Info |
---|
See 'Java Command Reference - Installing test listener as Java Agent' for more parameter values and information |
Sample of 'sealights' profile
Code Block | ||
---|---|---|
| ||
{ "executionType": "fullscanonly", "tokenFile": "sltoken.txt", "createBuildSessionId": true, "appName": "${JOB_NAME}", "branchName": "${GIT_BRANCH}", "buildName": "${BUILD_NUMBER}", "packagesIncluded": "*com.example.*", "packagesExcluded": "", "filesIncluded": "*.class", "filesExcluded": "*test-classes*", "recursive": true, "includeResources": true, "logEnabled": false, "logDestination": "console", "logLevel": "off", "logFolder": "/tmp", "sealightsJvmParams": {} } |
Frequently used parameters
Configuring SCM
SeaLights, by default, provides all links to the SCM for Github.
...
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 different than the one accessed by the users, then you can provide the base URL to use
sl.scm.version - set to the version of the on-premise version you use
Sample of SCM Parameters
Code Block |
---|
"sealightsJvmParams": { "sl.scm.provider": "bitbucket", "sl.scm.baseUrl": "https://{dns}/projects/{project}/repos/{repo}/browse", "sl.scm.version": "4.9.0" } |
Info |
---|
For more details and recommendations on how to set those 3 parameters, please refer to our dedicated page https://sealights.atlassian.net/l/c/300TDd3Y . |
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
Code Block |
---|
"sealightsJvmParams": { "sl.tags": "mytag", } |
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 scannerJar & listenerJar.
...
Note |
---|
The agents used here should be downloaded either with the latest agent or the recommended one as stated in Downloading the java agent files |
Integrating into the pom.xml files
Before running your maven build, you run the build scanner with -pom
flag to integrate the SeaLights Maven Plugin into the pom.xml files.
...
configfile - The path to the JSON configuration you created with the parameters to be provided to the SeaLights Maven Plugin
pluginversion - The version of the Maven SeaLights Plugin to insert into the pom.xml
workspacepath - The base path to the location of the pom.xml files to update
Sample Command
Code Block |
---|
java -jar sl-build-scanner.jar -pom -configfile slmaven.json -workspacepath . |
Note |
---|
This step will update all the |
Restoring the pom.xml file to its previous state
In case the pom file is to be restored to its previous state before the Sealights plugin was applied, use the build scanner with the -restore flag on the workspace where the pom.xml file is located:
Code Block |
---|
java -jar sl-build-scanner.jar -restorePom -workspacepath . |
Sample script
Info |
---|
Best Practice: This script is very often added to a dedicated pre-build step in the CI job (i.e. Jenkins). |
Code Block | ||
---|---|---|
| ||
echo "Downloading Sealights Agents..." wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip unzip -o sealights-java-latest.zip echo "Sealights agent version used is:" `cat sealights-java-version.txt` echo '{ "executionType": "scanonly", "tokenFile": "./sltoken.txt", "createBuildSessionId": true, "appName": "${JOB_NAME}", "branchName": "${GIT_BRANCH}", "buildName": "SL_Timestamp", "packagesIncluded": "*com.example.*", "packagesExcluded": "", "filesIncluded": "*.class", "filesExcluded": "*test-classes*", "recursive": true, "includeResources": true, "proxy": null, "logEnabled": false, "logDestination": "console", "logLevel": "warn", "logFolder": "/tmp/sl-logs", "sealightsJvmParams": { "sl.scm.provider": "github" }, "scannerJar": "./sl-build-scanner.jar", "listenerJar": "./sl-test-listener.jar", "filesStorage": "/tmp" }' > slmavensl-mvn-build.json echo "Updating POM with Sealights..." java -jar sl-build-scanner.jar -pom -configfile slmavensl-mvn-build.json -workspacepath . |
The next step is to run your regular maven command, typically like 'mvn clean install' or 'mvn clean verify'.
...