/
Java - How to ensure I am running the latest/recommended agent version

Java - How to ensure I am running the latest/recommended agent version

Problem

When configuring the SeaLights agent for Java, it is difficult to manage the .jar files are in the correct version - especially in standalone environments (containers, backend servers etc)

Solution

The following shell script checks for the recommended agent and latest version, and in case it does not exist locally - downloads & unzips it in the given directory.

Downloading the Recommended Agent set in settings

#!/bin/bash export DOMAIN=<CustomerDomain>.sealights.co export SEALIGHTS_AGENT_TOKEN=`cat sltoken.txt` if [ -f "sealights-java-agent.zip" ]; then export SL_LOCAL_VERSION=`cat sealights-java-version.txt` export SL_SETTINGS_VERSION=`curl -sX GET "https://$DOMAIN/sl-api/v1/agent-apis/agents/types/sealights-java/default-version" -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" -H "accept: application/json" | jq -r .version` if [ "${SL_LOCAL_VERSION}" == "${SL_SETTINGS_VERSION}" ]; then echo "Skipping Download - Local agent matches the current latest version:" $SL_SETTINGS_VERSION else echo "Local agent is not using the latest version. Deleting local agent." rm -fr sealights-java-* sl-*.jar fi fi if [ ! -f "sealights-java-agent.zip" ]; then echo "Downloading Java Agent version set in Settings..." wget -nv -O sealights-java-agents.zip --header "accept: application/json" --header "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \ https://$DOMAIN/api/v2/agents/sealights-java/recommended/download unzip -oq sealights-java-agents.zip echo "Local agent version is now:" `cat sealights-java-version.txt` fi

Downloading the latest agent

#!/bin/bash if [ -f "sealights-java-latest.zip" ]; then export LOCL_SL_VERSION=`cat sealights-java-version.txt` export CURR_SL_VERSION=`curl -s https://agents.sealights.co/sealights-java/sealights-java-version.txt` if [ "${LOCL_SL_VERSION}" == "${CURR_SL_VERSION}" ]; then echo "Skipping Download - Local agent matches the current latest version:" $CURR_SL_VERSION else echo "Local agent is not using the latest version. Deleting local agent." rm -fr sealights-java-* sl-*.jar fi fi if [ ! -f "sealights-java-latest.zip" ]; then echo "Downloading Sealights Latest Agent..." wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip unzip -o sealights-java-latest.zip echo "Local agent version is now:" `cat sealights-java-version.txt` fi









Related content

Downloading the java agent files
Downloading the java agent files
More like this
SeaLights Java agent - Command Reference
SeaLights Java agent - Command Reference
More like this
Using Java Agents - Running Tests
Using Java Agents - Running Tests
Read with this
.Net - How to ensure I am running the latest/recommended agent version
.Net - How to ensure I am running the latest/recommended agent version
More like this
Get Agent Default Version
Get Agent Default Version
More like this
How to make sure Sealights agent is up to date
How to make sure Sealights agent is up to date
More like this