SeaLights Jenkins Plugin - Installing Test Listener as Java Agent
There are two agent files Build Scanner - sl-build-scanner.jar Test Listener - sl-test-listener.jar Download them from: https://agents.sealights.co/sealights-java/sealights-java-latest.zipAgent Files
The build scanning and running tests are handled by the SeaLights Jenkins plugin using Maven. Therefore In order to capture code coverage on your backend server, you need to only install our test listener as a Java agent on the backend server.
Session ID
The SeaLights CLI config step generates the session ID to be used, see SeaLights Jenkins plugin - Generating a session ID
Server startup command
The test listener (sl-test-listener.jar) needs to be placed alongside the server and added to the JVM command line using the -javaagent parameter together with its required parameters.
- If the artifact was packaged using the Include Resources option, then Test Listener will find the token and session ID inside it therefore you only need to pass the javaagent parameter:
-javaagent:/path/to/sl-test-listener.jar
- If the artifact was not packaged using the Include Resources option, then the Test Listener needs to be provided the token and session ID as well:
-javaagent:/path/to/sl-test-listener.jar -Dsl.token=$SL_TOKEN -Dsl.buildSessionId=$SL_BUILD_SESSION_ID
See 'Java Command Reference - Installing test listener as Java Agent' for full parameter details
JBoss & Wildfly
When the application server is JBoss or WildFly, you should also update the following parameters:
jboss.modules.system.pkgs=io.sealights
JAVA_OPTS+="-javaagent:/path/to/sl-test-listener.jar -Dsl.token=$SL_TOKEN -Dsl.buildSessionId=$SL_BUILD_SESSION_ID -Djboss.modules.system.pkgs=org.jboss.byteman,io.sealights"
Spring boot maven plugin
When using the spring boot maven plugin, you can set the jvmArguments property in the configuration section of the plugin to define the needed arguments.
Note that if you are using the maven plugin you can use the ${sl.testListenerPath} instead of downloading and defining the actual test listener jar file.
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments>-javaagent:${sl.testListenerPath} -Dsl.token=${SL_TOKEN} -Dsl.buildSessionId=${SL_BUILD_SESSION_ID}</jvmArguments> </configuration> </plugin>
Jetty
Supported Jetty versions are: 9.1.1 and on
For the Jetty application server, if you are using the standard jetty.sh file then you can set the JAVA_OPTIONS environment variable with the javaagent, token and session ID.
Otherwise just add it to the JVM command you use to run jetty.
export JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:/path/to/sl-test-listener.jar -Dsl.token=$SL_TOKEN -Dsl.buildSessionId=$SL_BUILD_SESSION_ID"
Gradle build file
When using gradle to bring up a JVM with your application, you can set the javaagent in the jvmArgs
jvmArgs=["-javaagent:/path/to/sl-test-listener.jar", "-Dsl.token="+System.env.'SL_TOKEN', "-Dsl.buildSessionId="+System.env.'SL_BUILD_SESSION_ID']
WebSphere
In the admin console:
- Go to Servers→Application servers
- Select your server
- Go to Configuration→Service Infrastructure→Java and Process Management→Process Definition→Additional Properties→Java Virtual Machine
- Add the agent configurations in the Generic JVM arguments
-javaagent:/path/to/sl-test-listener.jar
WebLogic
In the admin console:
- Go to Environments→Servers
- Select your server
- Go to Server Start
- Add the agent configurations in the Arguments
-javaagent:/path/to/sl-test-listener.jar