# Command Reference

{% hint style="info" %}
**Passing Parameters as Environment Variables**

All of the below `sl-python` CLI parameters can be passed as an environment variable by prepending `SL_` to them.

For example,

* the param `buildname` would be set with `SL_BUILDNAME`
* the param `buildsessionid` would be set with `SL_BUILDSESSIONID`
* the param `proxy` would be set with `SL_PROXY`
  {% endhint %}

## Generating a session ID <a href="#generating-a-session-id" id="generating-a-session-id"></a>

### Standard Session ID <a href="#standard-session-id" id="standard-session-id"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python config {--token <token> | --tokenfile <file>} --appname <appname> --branchname <branch> --buildname <build> --workspacepath <path> [--include <include>] [--exclude <exclude>] [--buildsessionid <buildsessionid>] [--proxy <proxy>] [--help]
```

{% endcode %}

<table><thead><tr><th width="166.90234375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the Sealights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>appname</code></td><td>Name of the application</td></tr><tr><td><code>branchname</code></td><td>The source branch of the application</td></tr><tr><td><code>buildname</code></td><td>The build label of the current build</td></tr><tr><td><code>workspacepath</code></td><td>Path to the workspace where the source code exists</td></tr><tr><td><code>include</code></td><td>Include only files whose paths match one of these patterns.<br>Accepts shell-style wildcards, which must be quoted.<br>If you want to provide multiple patterns, please use a comma between each quoted pattern. For example, "pattern1", "pattern2".</td></tr><tr><td><code>exclude</code></td><td>Omit files whose paths match one of these patterns.<br>Accepts shell-style wildcards, which must be quoted.<br>If you want to provide multiple patterns, please use a comma between each quoted pattern. For example, "pattern1", "pattern2".</td></tr><tr><td><code>buildsessionid</code></td><td>Optional: A user provided session ID (case-sensitive)</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

### Pull Request Session ID <a href="#pull-request-session-id" id="pull-request-session-id"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python prConfig {--token <token> | --tokenfile <file>} --appname <appname> --targetbranch <branch> --latestcommit <commit_sha> --pullrequestnumber <number> --repourl <url> --workspacepath <path> [--include <include>] [--exclude <exclude>] [--buildsessionid <buildsessionid>] [--proxy <proxy>] [--help]
```

{% endcode %}

<table><thead><tr><th width="189.5703125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the Sealights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>appname</code></td><td>Name of the application</td></tr><tr><td><code>targetbranch</code></td><td>The branch to which this PR will be merged into (already reported to SeaLights)</td></tr><tr><td><code>latestcommit</code></td><td>The full SHA of the last commit made to the Pull Request</td></tr><tr><td><code>pullrequestnumber</code></td><td>he number assigned to the Pull Request from the source control</td></tr><tr><td><code>repourl</code></td><td>The pull request URL for the PR to be scanned, up until the section before the pullRequestNumber value</td></tr><tr><td><code>workspacepath</code></td><td>Path to the workspace where the source code exists</td></tr><tr><td><code>include</code></td><td>Include only files whose paths match one of these patterns.<br>Accepts shell-style wildcards, which must be quoted.</td></tr><tr><td><code>exclude</code></td><td>Omit files whose paths match one of these patterns.<br>Accepts shell-style wildcards, which must be quoted.</td></tr><tr><td><code>buildsessionid</code></td><td>Optional: A user provided session ID (case-sensitive)</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr></tbody></table>

## Scanning a build <a href="#scanning-a-build" id="scanning-a-build"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python scan {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --scm {git|none} [--scmBaseUrl <url> --scmProvider {github|gitlab|bitbucket} [--scmVersion <version>] [--proxy <proxy>] [--help]
```

{% endcode %}

<table><thead><tr><th width="192.671875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>buildsessionid</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildsessionidfile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>scm</code></td><td><p>Source control used</p><p>Current options are: git, none</p></td></tr><tr><td><code>scmprovider</code></td><td>The provider name of your Source Control Management (SCM) tool.<br>Values: Github, Bitbucket and Gitlab (Default is Github)</td></tr><tr><td><code>scmbaseurl</code></td><td><p>The URL to the repository which contains the code.</p><p>If not provided, the url of the remote GIT origin will be used</p><p>Example: <code>https://my.</code><a href="http://bitbucket.com/">bitbucket.com</a><code>/projects/ABCD/repos/XYZ/browse/A1</code></p></td></tr><tr><td><code>scmversion</code></td><td>The version of your Source Control Management (SCM) tool. If left blank, cloud version is assumed. Otherwise, specify the version of your on-premise server.</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

## Running backend server <a href="#running-backend-server" id="running-backend-server"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python run {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} [--cov-report <path>] [--per-test {true|false}] [--interval <interval>] [--labid <labid>] [--proxy <proxy>] [--help] args...
```

{% endcode %}

<table><thead><tr><th width="203.2265625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>buildsessionid</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildsessionidfile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>cov-report</code></td><td>Path to generate XML coverage report</td></tr><tr><td><code>per-test</code></td><td>Collect coverage per test (Default: false)</td></tr><tr><td><code>interval</code></td><td>Interval in milliseconds to send data</td></tr><tr><td><code>labid</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously (case-sensitive)</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr><tr><td><code>args...</code></td><td>Extra arguments for running the application server</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

## Test Listener <a href="#test-listener" id="test-listener"></a>

### Starting a test stage <a href="#starting-a-test-stage" id="starting-a-test-stage"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python start {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} --teststage <teststage> [--labid <labid>] [--proxy <proxy>] [--help]
```

{% endcode %}

<table><thead><tr><th width="190.8046875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>buildsessionid</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildsessionidfile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>teststage</code></td><td>Name of the test stage</td></tr><tr><td><code>labid</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr></tbody></table>

### Upload report files <a href="#upload-report-files" id="upload-report-files"></a>

Report files must be JUnit style XML reports

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python uploadReports {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} {--reportfile <reportFile> | --reportfilesfolder <reportFilesFolder>} [--hasmorerequests {False|True}] [--labid <labid>] [--source <source>] [--type <type>] [--proxy <proxy>] [--help]
```

{% endcode %}

<table><thead><tr><th width="196.26171875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>buildsessionid</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildsessionidfile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>reportfile</code></td><td>Path to report file. This argument can be declared multiple times in order to upload multiple files.</td></tr><tr><td><code>reportfilesfolder</code></td><td><p>Path to folder that contains nothing but report files. All files in folder will be uploaded.<br>This argument can be declared multiple times in order to upload multiple files from multiple folders containing report files.</p><p>Note: all files in the folder will be uploaded</p></td></tr><tr><td><code>hasmorerequests</code></td><td>Set to ‘True’ if test results contains multiple reports (Default: ‘False’).</td></tr><tr><td><code>labid</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously (case-sensitive)</td></tr><tr><td><code>source</code></td><td>The reports provider. If not set, the default will be 'Junit xml report'.</td></tr><tr><td><code>type</code></td><td><p>Name of testing framework type. The report type. If not set, the default will be 'JunitReport'</p><ul><li>JUnitReport - For uploading JUnit test report files</li><li>commitLog - For uploading git style commit logs</li></ul></td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr></tbody></table>

### Ending a test stage <a href="#ending-a-test-stage" id="ending-a-test-stage"></a>

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python end {--token <token> | --tokenfile <file>} {--buildsessionid <id> | --buildsessionidfile <file>} [--labid <labid>] [--proxy <proxy>] [--failbuild {true|false}]
```

{% endcode %}

<table><thead><tr><th width="193.35546875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenfile</code></td><td>Path to file containing access token generated from the SeaLights server</td></tr><tr><td><code>buildsessionid</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildsessionidfile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>labid</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through</td></tr><tr><td><code>help</code></td><td>Show Help message and exit.</td></tr></tbody></table>

### Running Tests via pytest, unittest, unit2 or nose  <a href="#running-tests-via-pytest-unittest-unit2-or-nose" id="running-tests-via-pytest-unittest-unit2-or-nose"></a>

These commands will be documented soon, please refer to their --help option via the command below

{% code overflow="wrap" lineNumbers="true" %}

```python
sl-python {pytest|unittest|unit2|nose} --help
```

{% endcode %}

## Logging <a href="#logging" id="logging"></a>

Enabling logging in Python is done using by setting the SL\_DEBUG environment variable to “true”.

Messages will be written to `stdout` and the file, `sealights-python-agent.log`

{% code overflow="wrap" lineNumbers="true" %}

```sh
export SL_DEBUG=true
```

{% endcode %}
