Skip to content

Remote Scan (CLI Analysis) ​

Remote scanning allows you to analyze code on your local machine or build server and push the results to the BrowserStack Code Quality server.

The Fast Way: Pipeline Script ​

The easiest way to perform a remote scan is to use the auto-generated script from the UI.

  1. Navigate to your Repository List.
  2. Click the Three Dots (...) in the top-right corner.
  3. Select Pipeline Script.
  4. Copy the generated script and execute it directly in your terminal at the root of your project.
Pipeline Script — copy and run the auto-generated scan commandClick to enlarge

The Manual Way: Step-by-Step ​

If you need to integrate the scanner into a custom pipeline, follow these three steps.

Step 1: Download the Scanner ​

Download and extract the CLI tool to your workspace. You can download directly using the link or the command below:

Download browserstack-codequality-scanner.tar.gz

bash
curl https://v1.embold.io/nfs/CLI/browserstack-codequality-scanner.tar.gz -o scanner.tar.gz
tar xvf scanner.tar.gz

Step 2: Configure Scan Settings ​

Before running a scan, you can customize what gets analysed. From the repository settings in the UI you can:

  • Enable or disable individual rules — tune the rule set to your team's standards
  • Add file / folder exclusions — skip generated code, third-party libraries, or test fixtures

→ See Advanced Scan Configuration for a full walkthrough.

Step 3: Get Repository Configuration ​

Download your specific repository-configuration.json. To find your Repository UID (RepoUID)

bash
curl --location --request GET "https://{{EMBOLD_SERVER_URL}}/api/v1/repositories/{REPUID}/scans/config/download" \
--header "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-o repository-configuration.json

Step 4: Execute the Scan ​

Viewing Available Commands and Options ​

To see all top-level commands supported by the scanner:

bash
./browserstack-codequality-scanner/bin/embold-scanner --help

Output:

Embold Commands:
1. analyse
2. embold-trace
3. local-analyse
4. gated-commit

Run 'embold-scanner COMMAND --help' for more information on a command.

To see all options available for the analyse command:

bash
./browserstack-codequality-scanner/bin/embold-scanner analyse --help

Running the Scan ​

Run the analyzer using the following command. Replace the placeholder values with your server details.

bash
./browserstack-codequality-scanner/bin/embold-scanner analyse \
  -u https://{{EMBOLD_SERVER_URL}} \
  -t $EMBOLD_TOKEN \
  -r {YOUR_REPO_UID} \
  -b . \
  -c ./repository-configuration.json \
  -d ./embold-data \
  -l ./embold-log \
  -sh ./embold-scanner-home

Minimum required flags: -u, -t, and -c.

Command Argument Reference ​

The table below lists all flags supported by the analyse command (as shown by analyse --help).

FlagLong FormDescription
-u--urlServer URL: Your BrowserStack Code Quality instance URL.
-t--tokenAccess Token: Generated under Settings > Access Tokens.
-c--scan-config-fileConfig Path: Path to your repository-configuration.json or YAML scan settings file.
-r--repository-uidRepository UID: Unique ID for the target repository in the Code quality UI.
-b--repository-base-dirBase Path: Root directory of the source code to scan (usually .).
-bc--repository-base-dirBuild Commands: embold-trace build commands.
-am--analysis-modeAnalysis Mode: Override the analysis mode.
-d--data-dirData Directory: Temporary working directory for scan data.
-sh--scanner-homeScanner Home: Path to the embold-scanner-home directory.
-l--scanner-logsLogs Directory: Directory where scanner logs are written.
-s--snapshot-labelSnapshot Label: Label for the snapshot published to the Code quality UI. Accepts an environment variable.
-sp--scan-profileScan Profile: Path to a scan profile XML file.
-si--session-idSession ID: Session identifier for the scan run.
-ssu--skip-source-uploadSkip Source Upload: Flag to skip uploading source files.
-lf--list-file-pathList File Path: Path to a file containing a list of files to scan.
-rn--revision-numberRevision Number: SCM revision (commit hash or number).
-ci--component-uidComponent UID: SCM component identifier.
-sd--snapshot-idSnapshot ID: ID of an existing snapshot to update.
-vd--vcs_detailsVCS Details: Version control system details.
-st--scm-tokenSCM Token: Required for license scans on private repositories.
-qg--quality-gate-statusQuality Gate: Show quality gate status after scan.
-nc--new-codeNew Code: Analyse new code only (currently supports code coverage).
-sc--starting-commitStarting Commit: Starting commit reference for new code coverage.
-pu----publishPublish: Continue scan and publish results even on non-fatal errors.
-v--verboseEnable verbose (debug) logging.
-h--helpDisplay help for the analyse command.

Performance Tuning ​

When running CLI analysis the scanner executes on your local machine or CI/CD agent — so memory and thread settings must be configured there, not on the server.

  • Memory — Control the analysis engine heap via the ANALYSER_XMX environment variable (e.g., export ANALYSER_XMX=-Xmx8g). Size this according to your repository's lines of code and the available RAM on the agent.
    → See Memory Settings Guide for size recommendations and examples.

  • Threads — Speed up analysis by increasing the thread count via EMB_ANALYSER_THREADS and EMB_PARSER_THREADS (e.g., export EMB_ANALYSER_THREADS=6). Match the thread count to the number of CPU cores available on the machine.
    → See Multi-Threaded Execution for a full guide.

Troubleshooting ​

  • Permissions: Ensure the bin/embold-scanner file has execute permissions (chmod +x).
  • Java: The scanner requires Java 1.8+ (check your environment with java -version).
  • Network: Ensure your build agent can reach the server URL provided in the -u flag.
  • Out of Memory: If the scan fails with heap errors, increase ANALYSER_XMX and ensure the machine has sufficient RAM. See Memory Settings Guide.

Repository Configuration ​

CI/CD Integration ​

Analysis & Workflows ​

Performance & Configuration ​

Help & Support ​