Hi,
I need help on the issue. I have my iOS project setup on Bitrise and getting error
the error log shows
**INFO: Parsing /Users/vagrant/git/sonarqube-generic-coverage.xml**
**INFO: ------------------------------------------------------------------------**
**INFO: EXECUTION FAILURE**
**INFO: ------------------------------------------------------------------------**
**INFO: Total time: 3:20.966s**
**INFO: Final Memory: 56M/200M**
**INFO: ------------------------------------------------------------------------**
**ERROR: Error during SonarScanner execution**
**ERROR: Error during parsing of the generic coverage report '/Users/vagrant/git/sonarqube-generic-coverage.xml'. Look at SonarQube documentation to know the expected XML format.**
**ERROR: Caused by: Line 882 of report refers to a file with an unknown language: /Users/vagrant/git/PetsBest/Plugins/inbox/DefaultTemplateHandler/MCEInboxDefaultTemplate.m**
**ERROR:**
**ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.**
The script that I am running inside Bitrise for Sonar execution is
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
brew install sonar-scanner
XML_OUTPUT="${BITRISE_SOURCE_DIR}/sonarqube-generic-coverage.xml"
echo " after XML Output file ..."
bash "${BITRISE_SOURCE_DIR}/bitriseShellScripts/xccov-to-sonarqube.sh" "$BITRISE_XCRESULT_PATH" 2>/dev/null 1> "$XML_OUTPUT"
echo "Running sonar-scanner on branch: $BITRISEIO_GIT_BRANCH_DEST"
#########################
# run the sonarqube scan
#
# sonarqube_access_token - is the Sonarqube server API Token generated for the project
# SONARQUBE_API_URL - is the Sonarqube API server url
# SONARQUBE_PROJECT_KEY - is the Sonarqube project key
#
# -Dsonar.branch.target="$BITRISEIO_GIT_BRANCH_DEST"
sonar-scanner \
-Dproject.settings=${BITRISE_SOURCE_DIR}/sonar-project.properties \
-Dsonar.language=swift \
-Dsonar.projectKey=$SONARQUBE_PROJECT_KEY \
-Dsonar.coverageReportPaths=${XML_OUTPUT} \
-Dsonar.host.url=$SONARQUBE_PATH \
-Dsonar.login=$SONARQUBE_TOKEN \
-Dsonar.issue.ignore.multicriteria=S3981,S1186 \
-Dsonar.issue.ignore.multicriteria.S3981.ruleKey=swift:S3981 \
-Dsonar.issue.ignore.multicriteria.S3981.resourceKey=PetsBest/Screens/HomeViewController.swift \
-Dsonar.issue.ignore.multicriteria.S1186.ruleKey=swift:S1186 \
-Dsonar.issue.ignore.multicriteria.S1186.resourceKey=PetsBest/Screens/**/*.swift \
-Dsonar.c.file.suffixes=- \
-Dsonar.cpp.file.suffixes=- \
-Dsonar.objc.file.suffixes=- \
-Dsonar.cfamily.build-wrapper-output.bypass=true \
-Dsonar.sourceEncoding=UTF-8 \
-Dsonar.coverage.exclusions=PetsBestTests/**,variable-injector/** \
-Dsonar.tests=PetsBestTests \
-Dsonar.branch.name=${BITRISE_GIT_BRANCH} \
-Dsonar.exclusions=PetsBest/Utils/AlertService.swift,PetsBest/Utils/APIRouter.swift,PetsBest/Application/AppDelegateConfigurator.swift,PetsBest/Application/AppUtility.swift,PetsBest/Utils/CustomSegmentedControl.swift,PetsBest/Utils/CustomWebView.swift,PetsBest/Utils/Extended/**,PetsBest/main.swift,PetsBest/Utils/ImagePicker.swift,PetsBest/Screens/MoreScreen/JS/index.js,PetsBest/Application/Pet+CoreDataProperties.swift,PetsBest/SceneDelegate.swift,PetsBest/Utils/Spinner.swift,PetsBest/Utils/StoreReviewHelper.swift,bitrise_shell_scripts/**,Pods/**,variable-injector/**
SCAN_COMPLETE="NO"
##
# Wait for the scan to complete
# sleep for 10 seconds first
#
sleep 15
# loop until we see a result from Sonarqube's project status API call
#
while [ $SCAN_COMPLETE = "NO" ]
do
SQ_STATUS=`curl -H "Authorization: bearer ${SONARQUBE_TOKEN}" ${SONARQUBE_PATH}/api/qualitygates/project_status\?pullRequest\="${BITRISE_PULL_REQUEST}"\&projectKey\=${SONARQUBE_PROJECT_KEY} | jq -r .projectStatus.status`
echo $SQ_STATUS
if [ $SQ_STATUS = 'OK' ] || [ $SQ_STATUS = 'ERROR' ] || [ $SQ_STATUS = 'WARN' ]
then
SCAN_COMPLETE="YES"
break
fi
sleep 5
done
# make the SQ_STATUS env variable available to the next step
#
envman add --key SQ_STATUS --value $SQ_STATUS
echo "Sonar scan done ......."
My xccov to sonarqube script is
**#!/usr/bin/env bash**
****set** -euo pipefail**
****function** convert_file {**
****local** xccovarchive_file="$1"**
****local** file_name="$2"**
****local** real_name=$(realpath $2)**
****local** xccov_options="$3"**
****echo** " <file path=\"$real_name\">"**
**xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \**
**sed -n '**
**s/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p;**
**s/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p**
**'**
****echo** ' </file>'**
**}**
****function** xccov_to_generic {**
****echo** '<coverage version="1">'**
****for** xccovarchive_file **in** "$@"; **do****
****local** xccov_options=""**
****if** [[ $xccovarchive_file == *".xcresult"* ]]; **then****
**xccov_options="--archive"**
****fi****
**xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | **while** **read** -r file_name; **do****
**convert_file "$xccovarchive_file" "$file_name" "$xccov_options"**
****done****
****done****
****echo** '</coverage>'**
**}**
**xccov_to_generic "$@"**