- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Enterprise Edition Version 10.2.1 (build 78527) - how is SonarQube deployed: zip, Docker, Helm
Jenkins - what are you trying to achieve
Code Coverage - what have you tried so far to achieve this
Changing the Coverage script file
Getting the following error
Xcode 15.1
**11:14:11** + bash ./xccov-to-sonarqube-generic.sh jenkinsreports/codecoverage/CodeCoverageResults.xcresult/
**11:14:13** Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load result bundle" UserInfo={NSLocalizedDescription=Failed to load result bundle, NSUnderlyingError=0x600001c246c0 {Error Domain=IDEFoundationSchemeActionErrorDomain Code=19 "The result bundle could not be opened as it is incomplete. Xcode might have failed to finish writing the result bundle." UserInfo={NSLocalizedDescription=The result bundle could not be opened as it is incomplete. Xcode might have failed to finish writing the result bundle.}}}
Script File Used
#!/usr/bin/env bash
set -euo pipefail
function convert_xccov_to_xml {
sed -n \
-e '/:$/s/&/\&/g;s/^\(.*\):$/ <file path="\1">/p' \
-e 's/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p' \
-e 's/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p' \
-e 's/^$/ <\/file>/p'
}
function xccov_to_generic {
local xcresult="$1"
echo '<coverage version="1">'
xcrun xccov view --archive "$xcresult" | while read -r line; do echo "${line#$PWD/}"; done | convert_xccov_to_xml
echo '</coverage>'
}
function check_xcode_version() {
local major=${1:-0} minor=${2:-0}
return $(( (major >= 14) || (major == 13 && minor >= 3) ))
}
if ! xcode_version="$(xcodebuild -version | sed -n '1s/^Xcode \([0-9.]*\)$/\1/p')"; then
echo 'Failed to get Xcode version' 1>&2
exit 1
elif check_xcode_version ${xcode_version//./ }; then
echo "Xcode version '$xcode_version' not supported, version 13.3 or above is required" 1>&2;
exit 1
fi
xcresult="$1"
if [[ $# -ne 1 ]]; then
echo "Invalid number of arguments. Expecting 1 path matching '*.xcresult'"
exit 1
elif [[ ! -d $xcresult ]]; then
echo "Path not found: $xcresult" 1>&2;
exit 1
elif [[ $xcresult != *".xcresult"* ]]; then
echo "Expecting input to match '*.xcresult', got: $xcresult" 1>&2;
exit 1
fi
xccov_to_generic "$xcresult"