Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
maxLevel2
printablefalse

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
Downloading the java agent files
Downloading the java agent files
nopaneltrue

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
  • If you override the surefire <argLine>...</argLine> then you need to add the SeaLights parameters inside the override value. See Surefire integration

  • Do not call the JSON file 'sealights.json' as the agent uses this file name for override options

  • For troubleshooting purpose,  you can use "buildName":"SL_Timestamp" in your JSON file to have the Sealights Maven plugin generating automatically a time stamp (yyyy.MM.dd-hh.mm format) as a default build name.

Info

See 'Java Command Reference - Installing test listener as Java Agent' for more parameter values and information

Sample of 'sealights' profile
Code Block
languagejson
{
  "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 pom.xml files and back them up to pom.xml.slback
You will need to restore them at the end of the run if you do not reset your workspace.

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
languagebash
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"
    }, 
    "enabledscannerJar": true, "./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 .

Next The next step is to run your regular maven command typicall , typically like 'mvn clean install' or 'mvn clean verify' for example.


Page Properties
hiddentrue


Related issues



...