Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Before running the build scan and tests, you need to create a session ID. The session ID is provided to each step in order link them together as one complete cycle

See 'Generating an Agent token' for instructions on how to generate a token

Agent File

Our Node.js agents (slnodejs) are published in the npm registry. You download it and all its dependencies using the npm repository commands.

Downloading latest version

npm i slnodejs

Downloading the recommended version by Sealights (Best Practice)

For Customers that need to set a specific recommended agent version other than the default latest, the API will provide the recommended agent version that has been set on the dedicated settings page from the dashboard.

In the following examples, replace $DOMAIN with your domain and $SL_TOKEN with your SeaLights agent token

Linux

# Fetch Agent version defined in Sealights dashboard settings 
$SLVERSION=$(curl -X GET "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -H "accept: application/json" -H "Authorization: Bearer $SL_TOKEN" -L)
# Install Sealights Agent (Recommended version)
npm i slnodejs@$SLVERSION

PowerShell

# Fetch Agent version defined in Sealights dashboard settings 
$SLVERSION = Invoke-RestMethod -Uri "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -Headers @{ "accept" = "application/json", "Authorization" = "Bearer $SL_TOKEN"}
# Install Sealights Agent (Recommended version)
npm i "slnodejs@$SLVERSION"

GitLab YML

  before_script:
    - apt-get -qq update && apt-get install -y jq
  script:
    - |
      SLVERSION=$(curl -X GET "https://$DOMAIN.sealights.co/api/v2/agents/slnodejs/recommended" -H "accept: application/json" -H "Authorization: Bearer $SL_TOKEN" -L  | jq -r .agent.version )
      npm install slnodejs@$SLVERSION

Generating a session ID in Node.js

Generating a session ID in Node.js is done using the SeaLights Node.js Agent with the config flag

Sample command on linux
Unix:
./node_modules/.bin/slnodejs config --tokenfile /path/to/sltoken.txt --appname "myApp" --branch "master" --build "1"

Windows:
call .\node_modules\.bin\slnodejs config --tokenfile \path\to\sltoken.txt --appname "myApp" --branch "master" --build "1"

See 'Node.js Command Reference - Creating a session ID' for full parameter details


Using the session ID

The session ID will be printed to the console output and a file called 'buildSessionId' will be generated containing it.

The file can be used as is in the agent parameters or can be used to fill in an environment parameter to be in a command line.

Copying token to environment variable
Unix:
export SL_BUILD_SESSION_ID=`cat buildSessionId`

Windows:
set /p SL_BUILD_SESSION_ID=<buildSessionId
  • No labels