LGTM Enterprise 1.19.2

Setting environment variables for worker hosts

You can set an environment variable across all worker host machines in the LGTM Enterprise work pool, or on specific worker hosts.

  1. On the coordinator server, edit the lgtm-cluster-config.yml file and locate the workers block.
  2. To set environment variables for:
    • All worker hosts—add an environment property at the same level as the hosts element.
    • A specific worker host—find the required hostname subsection and add an environment property at the same level as the general element.
  3. Below the environment property, add one or more environment variables and their values. Each on its own line, in the form: <ENVIRONMENT-VARIABLE>: "<value>".

  4. Save your changes then generate and deploy updated service configurations.

The environment variables specified in the cluster configuration file are passed to a systemd .env file for each worker. If you set a value that contains special characters, you must escape each of these characters appropriately. For example, a password of pass\word is specified as: pass\\word.

Built-in environment variables

LGTM Enterprise includes some built-in environment variables that you may find useful for configuring the work pool. For example, initially LGTM analysis has a memory limit of 6,656 MB. If this limit is exceeded, analysis fails. If some projects need more memory than this, you can set a different limit for one or more worker hosts using the environment variable LGTM_RAM (see the example in the topic on Assigning labels to workers).

Example

The extract from a cluster configuration file below includes two blocks of highlighted lines that set environment variables:

  1. The lines below the first environment label are part of the workers-host1 subsection and set values only for this worker host machine.
  2. The lines below the second environment label are part of the overall specification for worker host machines. They set values for all machines, except where they are overridden for a specific host.

This configuration sets values of ENV_VAR1 and ENV_VAR3 for all machines in the work pool. The host machine, workers-host1, has a different value for ENV_VAR1 and an additional environment variable: ENV_VAR2.

workers:

  hosts:

  - hostname: "lgtm-host"

    general: 1

    query: 1

  - hostname: "workers-host1"

    general: 2

    environment:

      ENV_VAR1: "override-default-value-on-workers-host1"

      ENV_VAR2: "value-set-only-on-workers-host1"

  temp_path: "/var/cache/lgtm/workers/"

  environment:

    ENV_VAR1: "value-to-use-on-all-workers"

    ENV_VAR3: "value-to-use-on-all-workers"

Example—putting tf on the PATH for TFVC checkout

To analyze projects stored in Team Foundation Version Control (TFVC), you must install the command-line client for TFS on machines that need to checkout the code (see Installing a command-line client for TFVC). After installing the client, you need to put the tf file on the PATH for LGTM workers.

LGTM workers are created by the LGTM application itself, and so any updates to the PATH are best defined in the cluster configuration file. In the example below, the PATH is set for all machines in the work pool to ensure that when new machines are added they can also checkout code from TFVC:

workers:

  hosts:

  - hostname: "lgtm-host"

    general: 1

    query: 1

  - hostname: "workers-host1"

    general: 2

  temp_path: "/var/cache/lgtm/workers/"

  environment:

    PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/TEE-CLC-14.134.0"

Related topicsRelated topics