Docker Image Paths and Configuration Options
Docker image paths
/data/project -- root directory of the project to be analyzed
/data/results -- directory to store the analysis results, needs to be empty before the Qodana run
/root/.config/idea -- idea configuration directory
/opt/idea -- directory of the idea distributive
/data/profile.xml -- used if a profile wasn't configured by run options or via
qodana.yaml
. See Order of resolving profile.
Configuring
Available arguments:
Examples of execution tuneup:
Override the default inspection profile:
docker run ... -v <inspection-profile.xml>:/data/profile.xml <image-name>Save a report in HTML. By default, the HTML report will be stored in a separate
report/
subdirectory under theresults
directory. This location could be configured with--report-dir
.docker run ... <image-name> --save-reportDisplay a report in HTML. After the inspection is finished, the container will not exit and will listen to port
8080
. You can connect tohttp://localhost:8080
to see the results. When done, you can stop the web server by pressingCtrl-C
in the Docker console.docker run ... -p 8080:8080 <image-name> --show-reportExtra Gradle settings:
docker run ... -v <source-directory>/gradle.properties:/root/.gradle/gradle.properties <image-name>Change the Heap size (default is 80% of host RAM):
docker run ... -e _JAVA_OPTIONS=-Xmx6g <image-name>Log INFO messages to STDOUT. By default, the log level for STDOUT is WARN.
docker run ... -e IDE_PROPERTIES_PROPERTY='-Didea.log.config.file=info.xml' <image-name>Use own
idea.properties
file:docker run ... -e IDEA_PROPERTIES=/data/project/idea.properties <image-name>
Order of resolving profile
Qodana checks the configuration parameters for resolving the inspection profile in this order:
Profile with the name
%name%
from the command line option-profileName %name%
.Profile by the path
%path%
from the command line option-profilePath %path%
.Profile with the name
%name%
fromqodana.yaml
.Profile by the path
%path%
fromqodana.yaml
.Profile mounted to
/data/profile.xml
.Fall back to using the embedded
qodana.recommended
profile.
Plugins management
The Qodana image contains selected Idea Ultimate plugins + PHP plugin.
Paid plugins are not yet supported. Each vendor must clarify licensing terms for CI usage and collaborate with us to make it work.
You can add any free IntellJ platform plugins or your custom plugin using the following command:
To optimize the most common cases, some bundled plugins are disabled by default. You can check the whole list of disabled plugins in /root/.config/idea/disabled_plugins.txt
.
By default are enabled: Java, Kotlin for Server Side, PHP, and their libraries/frameworks' plugins. Gradle and Maven plugins are also enabled.
To change the plugins list, do any of the following:
Override
disabled_plugins.txt
by mounting your own file:docker run ... -v $empty_file$:/root/.config/idea/disabled_plugins.txt <image-name>Use IDE properties
idea.required.plugins.id
andidea.suppressed.plugins.id
:docker run ... -e IDE_PROPERTIES_PROPERTY='-Didea.required.plugins.id=JavaScript,org.intellij.grails' <image-name>or
docker run ... -e IDE_PROPERTIES_PROPERTY=' -Didea.suppressed.plugins.id=com.intellij.spring.security' <image-name>
Analyze changes
Qodana allows checking only changed files:
You can adjust the idea.required.plugins.id
value and keep only the CVS plugin suitable for your project.
Run as non-root
By default, the container runs as root
user, so Qodana would be able to read any bind-mounted volumes with the project and write the results. Which also leads to files in results/
folder owned by root
after the run.
To avoid this, you can run container as a current user:
Note that in this case, the results/
folder on host should already be created and owned by you. Otherwise, Docker will create it as root
and Qodana will be unable to write to it.
Cache dependencies
You can decrease the time for Qodana run by persisting cache from one run to another. For example, package and dependency management tools such as Maven, Gradle, npm, and Yarn keep a local cache of downloaded dependencies.
By default, Qodana would save caches to folder /data/cache
inside container. This location could be changed via --cache-dir
cli argument. The data inside is per-repository, so you can pass cache from branch-a
to build checking branch-b
. In this case, only new dependencies would be downloaded, if they were added. The cache feature is available starting from 2021.1-eap
image.
Example for local run:
docker run --rm -it -p 8080:8080 \ -v <source-directory>/:/data/project/ \ -v <output-directory>/:/data/results/ \ -v <cache-directory>/:/data/cache/ \ jetbrains/qodana --show-report
In this case mapping the same <cache-directory>
would speedup second run.
In GitHub workflow you can utilise actions/cache, see full example.
GitLab CI also has cache which can be stored only inside the project directory. In this case, we recommend excluding the cache folder from inspection via qodana.yaml.
Turn off user statistics
To disable the reporting of usage statistics, adjust the idea.headless.enable.statistics
value: