For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sample PR integrations in CI

We have captured here typical use cases of Pull Request Integration.

Maven Build for a Java application

In the example below, we simply create the buildSessionId outside the JSON command using the relevant parameters.

name: Build with Sealights
on:
  push:
    branches:
      - "**"
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      SL_TOKEN: ${{ secrets.SL_TOKEN }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: "17"
          distribution: "temurin"
      - name: Download Sealights Agents
        # NOTE: The steps below can be consolidated into a shell script (e.g. sealights-setup.sh) per best practice
        run: |
          echo "Downloading Sealights Agents..."
          wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip
          unzip -o sealights-java-latest.zip
      - name: Create Sealights' UUID (BSID) according to context
        # NOTE: This step can be moved to a shell script (e.g. sealights-config.sh) per best practice
        env:
          SL_APP_NAME: ${{ github.event.repository.name }}
          SL_PACKAGES_INCLUDED: "*com.mycompany.*" ## UPDATE ME ! ##
          PR_NUMBER: ${{ github.event.pull_request.number }}
          PR_BASE_BRANCH: ${{ github.base_ref }}
          COMMIT_SHA: ${{ github.sha }}
          REPO_NAME: ${{ github.repository }}
          BRANCH_NAME: ${{ github.ref_name }}
        run: |
         if [ -n "${PR_NUMBER}" ]; then
            # Pull Request context (GitHub Actions environment variables)
            java -jar sl-build-scanner.jar -prConfig \
              -token "${SL_TOKEN}" \
              -appname "${SL_APP_NAME}" \
              -targetBranch "${PR_BASE_BRANCH}" \
              -pullRequestNumber "${PR_NUMBER}" \
              -latestCommit "${COMMIT_SHA}" \
              -repoUrl "https://github.com/${REPO_NAME}" \
              -pi "${SL_PACKAGES_INCLUDED}"
          else
            # Regular Build
            BUILD_NUMBER="${{ github.run_number }} ($(date -u '+%Y-%m-%d %H:%M'))"
            java -jar sl-build-scanner.jar -config \
              -token "${SL_TOKEN}" \
              -appname "${SL_APP_NAME}" \
              -branchname "${BRANCH_NAME}" \
              -buildname "${BUILD_NUMBER}" \
              -pi "${SL_PACKAGES_INCLUDED}"
          fi
      - name: Generate Sealights Maven Config and Update POM
        # NOTE: This step can be moved to a shell script (e.g. sealights-maven-config.sh) per best practice
        run: |
          cat > slmaven.json << 'EOF'
          {
            "executionType": "full",
            "token": "${SL_TOKEN}",
            "createBuildSessionId": false,
            "buildSessionIdFile": "./buildSessionId.txt",
            "filesIncluded": "*.class",
            "filesExcluded": "*test-classes*",
            "recursive": true,
            "includeResources": true,
            "testStage": "Unit Tests",
            "labId": null,
            "logEnabled": false,
            "logDestination": "console",
            "logLevel": "off",
            "logFolder": "/tmp/sl-logs",
            "sealightsJvmParams": {},
            "enabled": true,
            "filesStorage": "/tmp"
          }
          EOF
          echo "Updating POM with Sealights..."
          java -jar sl-build-scanner.jar -pom -configfile slmaven.json -workspacepath .
      - name: Build with Maven
        run: mvn clean install

In the sample script below, please update lines 7 and 8 before executing it.

Azure DevOps Pipeline for a DotNet application

In the sample script below, if required, please update lines 1 to 4 and 25-26 before executing it.

Lines 8-9, 22-23 and 26-27 contain the ` characters allowing multi-line commands in Powershell scripts, to increase readiness of this sample code.

Last updated

Was this helpful?