We have a connection timeout issue with SonarCloud and our azure devops pipeline running in a docker container on a self-hosted agent in our corporate network. We have set the usual network proxy needed, but somehow connection still isn’t possible for the sonar cloud client. The Build log shows (more details in the attached build error log below):
ERROR Failed to query JRE metadata: Call to URL [https://api.sonarcloud.io/analysis/jres?os=linux&arch=x86_64] failed: HTTP connect timed out
This is the corresponding relevant part in the azure build pipeline:
- task: SonarCloudPrepare@4
inputs:
SonarCloud: "SonarQube Cloud"
organization: "myCorp"
scannerMode: "CLI"
configMode: "file"
extraProperties: |
sonar.cfamily.compile-commands=build_wrapper_output_directory/compile_commands.json
env:
https_proxy: 'http://myproxy.com:80'
http_proxy: 'http://myproxy.com:80'
- script: |
cd $(Pipeline.Workspace)/$(project_folder)
cmake --preset=Release
build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory cmake --build ./Release
mkdir -p '$(Build.ArtifactStagingDirectory)/Artifacts/Release'
cp out/*.bin '$(Build.ArtifactStagingDirectory)/Artifacts/Release/'
cp Release/SysBiosAppl/*.out '$(Build.ArtifactStagingDirectory)/Artifacts/Release/'
exit $?
displayName: "Running Build CMake, wrapped by SonarQube"
condition: always()
- task: SonarCloudAnalyze@4
displayName: 'SonarCloudAnalyze'
inputs:
jdkversion: 'JAVA_HOME'
extraProperties: sonar.verbose=true
env:
https_proxy: 'http://myproxy.com:80'
http_proxy: 'http://myproxy.com:80'
- task: SonarCloudPublish@4
displayName: 'SonarCloudPublish'
inputs:
pollingTimeoutSec: '500'
extraProperties: sonar.verbose=true
env:
https_proxy: 'http://myproxy.com:80'
http_proxy: 'http://myproxy.com:80'
Here’s the linux-based Dockerfile for the sonarcloud layer we put on top of the image to build our embedded gcc-based C code project using cmake:
FROM myproject.azurecr.io/docker-base-image-ccs:CCS12_V01.01.11
ARG user_name
ARG home_dir
COPY ./build-wrapper-linux-x86.zip .
RUN mkdir -p ${home_dir}/.sonar \
&& chmod 777 ${home_dir}/.sonar/
RUN unzip -o build-wrapper-linux-x86.zip -d ${home_dir}/.sonar/
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV PATH=${home_dir}/.sonar/build-wrapper-linux-x86:${PATH}
ENV https_proxy=http://myproxy.com:80
ENV http_proxy=http://myproxy.com:80
ENV JAVA_TOOL_OPTIONS="\
-Dhttp.proxyHost=myproxy.com \
-Dhttp.proxyPort=80 \
-Dhttps.proxyHost=myproxy.com \
-Dhttps.proxyPort=80 \
-Dhttp.nonProxyHosts=localhost|127.0.0.1 \
"
At the moment we feel that for some reason the proxy setting is not being picked up by the sonar client, because when I issue a curl command in an interactive bash shell inside the same container on the same agent, it works fine and I get a proper response:
curl -X ‘GET’ ‘https://api.sonarcloud.io/analysis/jres?os=linux&arch=x86_64’ -H ‘accept: application/json’
Anybody any ideas how to solve this?