* Code scanning troubleshooting: Set up environment with CodeQL runner * Change "trace" to "monitor" * Fix note syntax
4.1 KiB
title, shortTitle, intro, product, versions
| title | shortTitle | intro | product | versions | ||||
|---|---|---|---|---|---|---|---|---|
| Troubleshooting code scanning in your CI system | Troubleshooting in your CI | If you're having problems with the {{ site.data.variables.product.prodname_codeql_runner }}, you can troubleshoot by using these tips. | {{ site.data.reusables.gated-features.code-scanning }} |
|
{{ site.data.reusables.code-scanning.beta }} {{ site.data.reusables.code-scanning.enterprise-enable-code-scanning }}
The init command takes too long
Before the {{ site.data.variables.product.prodname_codeql_runner }} can build and analyze code, it needs access to the {{ site.data.variables.product.prodname_codeql }} bundle, which contains the {{ site.data.variables.product.prodname_codeql }} CLI and the {{ site.data.variables.product.prodname_codeql }} libraries.
When you use the {{ site.data.variables.product.prodname_codeql_runner }} for the first time on your machine, the init command downloads the {{ site.data.variables.product.prodname_codeql }} bundle to your machine. This download can take a few minutes.
The {{ site.data.variables.product.prodname_codeql }} bundle is cached between runs, so if you use the {{ site.data.variables.product.prodname_codeql_runner }} again on the same machine, it won't download the {{ site.data.variables.product.prodname_codeql }} bundle again.
To avoid this automatic download, you can manually download the {{ site.data.variables.product.prodname_codeql }} bundle to your machine and specify the path using the --codeql-path flag of the init command.
No code found during the build
If the analyze command for the {{ site.data.variables.product.prodname_codeql_runner }} fails with an error No source code was seen during the build, this indicates that {{ site.data.variables.product.prodname_codeql }} was unable to monitor your code. Several reasons can explain such a failure.
-
Automatic language detection identified a supported language, but there is no analyzable code of that language in the repository. A typical example is when our language detection service finds a file associated with a particular programming language like a
.h, or.gypfile, but no corresponding executable code is present in the repository. To solve the problem, you can manually define the languages you want to analyze by using the--languagesflag of theinitcommand. For more information, see "Configuring {{ site.data.variables.product.prodname_code_scanning }} in your CI system." -
You're analyzing a compiled language without using the
autobuildcommand and you run the build steps yourself after theinitstep. For the build to work, you must set up the environment such that the {{ site.data.variables.product.prodname_codeql_runner }} can monitor the code. Theinitcommand generates instructions for how to export the required environment variables, so you can copy and run the script after you've run theinitcommand.- On macOS and Linux:
$ . codeql-runner/codeql-env.sh - On Windows, using the Command shell (
cmd) or a batch file (.bat):> call codeql-runner\codeql-env.bat - On Windows, using PowerShell:
> cat codeql-runner\codeql-env.sh | Invoke-Expression
The environment variables are also stored in the file
codeql-runner/codeql-env.json. This file contains a single JSON object which maps environment variable keys to values. If you can't run the script generated by theinitcommand, then you can use the data in JSON format instead.{% note %}
Note: If you used the
--temp-dirflag of theinitcommand to specify a custom directory for temporary files, the path to thecodeql-envfiles might be different.{% endnote %}
- On macOS and Linux:
-
The code is built in a container or on a separate machine. If you use a containerized build or if you outsource the build to another machine, make sure to run the {{ site.data.variables.product.prodname_codeql_runner }} in the container or on the machine where your build task takes place.