/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner: line 66: /private/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/jre/bin/java: cannot execute binary file
/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner: line 66: /private/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/jre/bin/java: Undefined error: 0
Exited with code exit status 1
CircleCI received exit code 1
Steps to reproduce
Seems like from your tutorial that the Linux orb is the only official orb available for Circle CI. I’m really at a loss understanding your documentation as to how to get my code coverage results uploaded to Sonarcloud.
We were setup using automatic analysis but then read (Enriching Your Analysis | SonarCloud Docs) that code coverage features were available only with CI-Analysis, so we changed that and realized that the orb only supports Linux. I think that’s where we’re currently stuck.
Can you provide the full log, starting from the analysis command?
Also, it appears that you’re converting your coverage report to the Generic Coverage report format and then attempting to import it as an llvm-cov show report. That’s not going to work. If you’re producing a Generic Coverage report, analysis needs to consume it as sonar.coverageReportPaths.
I don’t run the analysis command directly. Am I missing a step? I run tests and get a xcresult file that is then converted to the generic format. Should I run another type of analysis before scan?
Here is the full output from the sonarcloud scan step from CircleCI. It seems like it’s assuming this is a linux machine, not a macOS-based VM from Circle as needed for Swift development.
#!/bin/bash --login -o pipefail
set -e
VERSION=4.6.2.2472
SONAR_TOKEN=$SONAR_TOKEN
SCANNER_DIRECTORY=/tmp/cache/scanner
export SONAR_USER_HOME=$SCANNER_DIRECTORY/.sonar
OS="linux"
echo $SONAR_USER_HOME
if [[ ! -x "$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner" ]]; then
curl -Ol https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION-$OS.zip
unzip -qq -o sonar-scanner-cli-$VERSION-$OS.zip -d $SCANNER_DIRECTORY
fi
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/jre/bin/java
$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
/tmp/cache/scanner/.sonar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 41.1M 100 41.1M 0 0 74.8M 0 --:--:-- --:--:-- --:--:-- 75.8M
/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner: line 66: /private/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/jre/bin/java: cannot execute binary file
/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner: line 66: /private/tmp/cache/scanner/sonar-scanner-4.6.2.2472-linux/jre/bin/java: Undefined error: 0
Exited with code exit status 1
CircleCI received exit code 1
Yeah, that looks like the problem. We only offer a Linux integration for CircleCI. Instead of using the orb, you’ll need to execute SonarScanner manually. There’s a path through the onboarding wizard that brings you to those instructions if you use “use another CI”
Regarding the the coverage report, I was looking at this:
You’re going to get a Generic Coverage report out of that, so you want to use the corresponding sonar.coverageReportPaths parameter to pass it in, not the sonar.swift.coverage.reportPaths parameter.