CodeScene CLI tool
==================

.. include:: ../../shared/cli/binary-installation.rst

Client setup
------------

The CLI tool requires a user with a Technical role - see :doc:`../configuration/users-and-roles`. The user should create a Personal Access Token at `https://your.codescene.com/configuration/user/token`.

Then set your environment variables as follows:

.. code-block:: console

    export CS_ONPREM_URL=<https://your.codescene.com>
    export CS_ACCESS_TOKEN=<your-token>

Or in Windows PowerShell:

.. code-block:: console

    $env:CS_ONPREM_URL = '<https://your.codescene.com>'
    $env:CS_ACCESS_TOKEN = '<your-token>'

Here are the main ways to set environment variables in Windows Command Prompt:

Temporary (for current session only):

.. code-block:: console
    
    SET CS_ACCESS_TOKEN=<your-access-token>
    SET CS_ONPREM_URL=<https://your.codescene.com>

Permanent (using setx command):

.. code-block:: console

    SETX CS_ACCESS_TOKEN=<your-access-token>
    SETX CS_ONPREM_URL=<https://your.codescene.com>

Note: Changes made with SETX require reopening Command Prompt to take effect

You can set environment variables in Windows through the System Properties dialog. Here's how to access it:

1. Right-click on "This PC" or "My Computer"
2. Click "Properties"
3. Click "Advanced system settings"
4. Click "Environment Variables" button near the bottom

Or the faster way:

1. Press Windows key + R
2. Type "sysdm.cpl"
3. Go to "Advanced" tab
4. Click "Environment Variables"

Off-line use
------------

Once the CLI tool has sucessfully authenticated with the server once, it can be used offline until the end of the server's license period. The off-line license is stored in the directory defined by ``CODESCENE_HOME`` environment variable. If you want to run offline in builds such as GitHub actions you'll can copy this folder into the docker image.

If environment variable ``CODESCENE_HOME`` is not set:

- in Windows it is ``$APP_DATA/Codescene``
- else it is ``.codescene`` directory in user home directory

Other topics
------------

.. toctree::
  :maxdepth: 1

  command-reference