LGTM Enterprise 1.21.1

Configuring hosts to analyze code

During the analysis of compiled languages, LGTM builds the code. This means that each worker host must be configured with the environment needed to build the codebases that you want to analyze on that machine. Interpreted languages often also depend on the presence of other software in the environment, and these must be made available too. You can specify environment variables for all, or for individual worker hosts in the cluster configuration file. For more details, see Setting environment variables for worker hosts.

Determining what to install

In general, worker host machines should be set up in much the same way as you set up a continuous integration (CI) slave—with the software and environment required by the projects you plan to analyze on that machine.

Core requirements

The core requirements listed below are the minimum required to analyze code written in each language. Your projects may have additional requirements. Compiled languages have further requirements (detailed in the following section).

Language Essential
C/C++

Method of building the code (see next table).

C#

Method of building the code (see next table).

COBOL

No further requirements.

Java

Method of building the code (see next table).

JavaScript

No further requirements unless any TypeScript files are present.

If the repository also includes TypeScript files, the TypeScript requirements must be met, or TypeScript analysis disabled.

Python

Access to the pip packaging management system.

Installation of the packaging and virtualenv pip modules.

Ability to download any packages that the Python codebases you intend to analyze depend on.

TypeScript

Node.js version 6.x or later.

Compiled languages

For compiled code that is normally built using one of the most commonly used build systems (listed in the following table), LGTM Enterprise has an "autobuild" process which is designed to automatically build the code. If your organization uses these build systems, install them on the relevant worker machines. If some projects use other build systems, you also need to make these systems available. These projects will require a custom build configuration.

Language Autobuild available for
C/C++

Linux workers: Autoconf, CMake, QMake, Meson, WAF, SCons, and Linux KBuild

Windows workers: MSBuild

C#

MSBuild, .NET Core, Mono (Linux), and Visual Studio (Windows)

Java

Gradle, Maven and Ant

If you set up machines with different build environments for different types of project, set worker labels so that you can define which languages/projects are analyzed by each type of worker. For more information about setting worker labels, see Setting environment variables for worker hosts.

Checking the basic configuration

Linux machines

You can use the lgtm-build-requirements command to check whether the basic dependencies and environment for building/analyzing projects using the default build methods supported by LGTM Enterprise are set up correctly.

On each Linux machine that runs worker daemons, run the command:

sudo lgtm-build-requirements

If you're not the root user you need to use sudo to run the lgtm-build-requirements command.

This command checks the machine for basic checkout and build requirements. Any systems that are accessible to LGTM workers are reported with a success message. For example:

[info] Python
[success] python2 found.
[success] pip for python2 found.
[success] packaging for python2 found.
[success] virtualenv for python2 found.
[error] python3 was not found. You are unlikely to be able to analyze any Python 3 projects.

In this example, the command successfully found the core dependencies for Python 2 analysis but not for Python 3 analysis.

Windows machines

When you use install-machine.bat to deploy LGTM workers, the script sets the LGTM worker daemons to run under the account that you specify when you run the script. Alternatively, if you don't specify an account the LocalSystem account is used.

After installing the build tools that you need, check that they are available on the path for this account, and that an appropriate version of Python is also available on the path.

Setting up a host for JavaScript and TypeScript analysis

Analysis of JavaScript code has no additional dependencies.

If a project includes TypeScript files (.ts and .tsx) you must install Node.js 6.x or later (we recommend the latest LTS version) on any worker host machines that will be used to analyze this code.

Linux machines

Check whether Node is available by running the lgtm-build-requirements command:

[sudo] lgtm-build-requirements

If the command returns the message [warning] node was not found, install Node.js 6.x or later (LTS version recommended).

Windows machines

Check whether Node is available by requesting the version number:

node -v

If the command returns the message 'node' is not recognized..., install Node.js 6.x or later (LTS version recommended) and add it to the path.

Setting up a host for Python analysis

Extraction of Python code relies on access to the pip packaging management system, and installation of the packaging and virtualenv pip modules.

Linux machines

  • To check on the availability of pip, run the following command on each worker:
    python -c 'import pip'
    If pip is available, the prompt returns without comment. Otherwise an error is reported.
  • To install pip:
    • On RedHat or CentOS run: sudo yum -y install python-pip
    • On Debian or Ubuntu run: sudo apt-get install python-pip
  • To install the packaging and virtualenv modules, run:
    • sudo pip install packaging virtualenv

Windows machines

  • To check on the availability of pip, run the following command on each worker:
    python -m pip --version
    If pip is available, the version number is reported. Otherwise an error is reported.
  • To install pip:
    1. Download get-pip.py to the machine.
    2. Open a command prompt window and navigate to the directory containing get-pip.py.
    3. Run python get-pip.py. This will install pip.
    4. Check that pip is now available. If you still see an error, add pip to the path.
  • To install the packaging and virtualenv modules, run:
    • python -m pip install packaging virtualenv

Related topicsRelated topics