Running behind a proxy server
Depending on your needs, you can run Qodana behind a proxy server using an existing Qodana Docker image, or create a Docker image from scratch.
Follow these steps to prepare an existing Qodana Docker image to run behind a proxy server:
Create the
proxy.settings.xmlfile and save it in the.qodanadirectory of your project root.In the
proxy.settings.xmlfile, save information about the proxy server that will be used by Qodana:<application> <component name="HttpConfigurable"> <option name="USE_HTTP_PROXY" value="true" /> <option name="PROXY_HOST" value="<ProxyHost>" /> <option name="PROXY_PORT" value="<ProxyPort>" /> <!-- Add more settings as needed --> </component> </application>In the
qodana.yamlfile, save thisboostrapcommand that will copy theproxy.settings.xmlfile to a Qodana Docker image:boostrap: cp .qodana/proxy.settings.xml /root/.config/idea/options/proxy.settings.xmlRun Qodana using proxy server settings specified in the
JAVA_TOOL_OPTIONSenvironment variable:docker run \ -v $(pwd):/data/project/ \ -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" \ -e QODANA_TOKEN="<cloud-project-token>" \ jetbrains/qodana-<image>qodana scan \ -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" \ -e QODANA_TOKEN="<cloud-project-token>"pipeline { environment { QODANA_TOKEN=credentials('qodana-token') } agent { docker { args ''' -v "${WORKSPACE}":/data/project -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort> " --entrypoint="" ''' image 'jetbrains/qodana-<image>' } } stages { stage('Qodana') { steps { sh ''' qodana ''' } } } }image: atlassian/default-image:4 pipelines: branches: main: - step: name: Qodana caches: - qodana image: jetbrains/qodana-<image> # Specify a Qodana linter here. For example, jetbrains/qodana-jvm:latest script: - export QODANA_TOKEN=$QODANA_TOKEN # Export the environment variable - export JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" - qodana --results-dir=$BITBUCKET_CLONE_DIR/.qodana --report-dir=$BITBUCKET_CLONE_DIR/.qodana/report --cache-dir=~/.qodana/cache artifacts: - .qodana/report definitions: caches: qodana: .qodana/cache
To create your custom Qodana image containing proxy server settings, follow this procedure:
Create the
proxy.settings.xmlfile and save proxy server settings in it:<application> <component name="HttpConfigurable"> <option name="USE_HTTP_PROXY" value="true" /> <option name="PROXY_HOST" value="<ProxyHost>" /> <option name="PROXY_PORT" value="<ProxyPort>" /> <!-- Add more settings as needed --> </component> </application>Use this sample to create the
Dockerfile:FROM docker.io/jetbrains/qodana-<image>:2025.3<-eap> LABEL version="1.0.0" ##Copy the proxy.settings.xml file COPY proxy.settings.xml /root/.config/idea/options/proxy.settings.xml ##Copy the gradle.properties file (optional) COPY gradle.properties ~/.gradle/gradle.properties ##Install certificates COPY <your_certificate> <path_to_certificate> RUN $JAVA_HOME/bin/keytool -import -trustcacerts -alias dc-ca -keystore $JAVA_HOME/lib/security/cacerts -noprompt -storepass changeit -file <path_to_certificate> COPY <your_certificate> /etc/ssl/certs RUN chmod 444 /etc/ssl/certs/<your_certificate> ##Set proxy ENV http_proxy <proxy> ENV https_proxy <proxy> ENV HTTP_PROXY <proxy> ENV HTTPS_PROXY <proxy> ENV ftp_proxy $http_proxy ENV dns_proxy $http_proxy ENV rsync_proxy $http_proxyRun Qodana using proxy server settings configured in the
JAVA_TOOL_OPTIONSenvironment variable:docker run \ -v $(pwd):/data/project/ \ -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" \ -e QODANA_TOKEN="<cloud-project-token>" \ <image>qodana scan \ -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" \ -e QODANA_TOKEN="<cloud-project-token>" \ --image <image>pipeline { environment { QODANA_TOKEN=credentials('qodana-token') } agent { docker { args ''' -v "${WORKSPACE}":/data/project -e JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort> " --entrypoint="" ''' image '<image>' } } stages { stage('Qodana') { steps { sh ''' qodana ''' } } } }image: atlassian/default-image:4 pipelines: branches: main: - step: name: Qodana caches: - qodana image: jetbrains/qodana-<image> # Specify a Qodana linter here. For example, jetbrains/qodana-jvm:latest script: - export QODANA_TOKEN=$QODANA_TOKEN # Export the environment variable - export JAVA_TOOL_OPTIONS="-Dhttps.proxyHost=<ProxyHost> -Dhttps.proxyPort=<ProxyPort> -Dhttp.proxyHost=<ProxyHost> -Dhttp.proxyPort=<ProxyPort>" - qodana --results-dir=$BITBUCKET_CLONE_DIR/.qodana --report-dir=$BITBUCKET_CLONE_DIR/.qodana/report --cache-dir=~/.qodana/cache artifacts: - .qodana/report definitions: caches: qodana: .qodana/cache