CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'sonar' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; FLUSH PRIVILEGES;
#!/bin/bash ## INSTALLATION: script to copy in your Xcode project in the same directory as the .xcodeproj file ## USAGE: ./run-sonar.sh ## DEBUG: ./run-sonar.sh -v ## WARNING: edit your project parameters in sonar-project.properties rather than modifying this script #
# Run a set of commands with logging and error handling function runCommand() {
# 1st arg: redirect stdout # 2nd arg: command to run # 3rd..nth arg: args redirect=$1 shift
command=$1 shift if [ "$nflag" = "on" ]; then # don't execute command, just echo it echo if [ "$redirect" = "/dev/stdout" ]; then if [ "$vflag" = "on" ]; then echo "+" $command "$@" else echo "+" $command "$@" "> /dev/null" fi elif [ "$redirect" != "no" ]; then echo "+" $command "$@" "> $redirect" else echo "+" $command "$@" fi elif [ "$vflag" = "on" ]; then echo
if [ "$redirect" = "/dev/stdout" ]; then set -x #echo on $command "$@" returnValue=$? set +x #echo off elif [ "$redirect" != "no" ]; then set -x #echo on $command "$@" > $redirect returnValue=$? set +x #echo off else set -x #echo on $command "$@" returnValue=$? set +x #echo off fi if [[ $returnValue != 0 && $returnValue != 5 ]] ; then stopProgress echo "ERROR - Command '$command $@' failed with error code: $returnValue" exit $returnValue fi else echo "--------------------------------" echo $command echo "$@" if [ "$redirect" = "/dev/stdout" ]; then $command "$@" > /dev/null elif [ "$redirect" != "no" ]; then $command "$@" > $redirect else $command "$@" fi
returnValue=$? if [[ $returnValue != 0 && $returnValue != 5 ]] ; then stopProgress echo "ERROR - Command '$command $@' failed with error code: $returnValue" exit $? fi
echo fi }
## COMMAND LINE OPTIONS vflag="" nflag="" oclint="on" while [ $# -gt 0 ] do case "$1" in -v) vflag=on;; -n) nflag=on;; -nooclint) oclint="";; --) shift; break;; -*) echo >&2 "Usage: $0 [-v]" exit 1;; *) break;; # terminate while loop esac shift done
# Usage OK echo "Running run-sonar.sh..."
# 检查依赖是否已经安装 xcpretty and oclint echo "check xcodebuild, oclint installed is installed" testIsInstalled xcodebuild testIsInstalled xcpretty testIsInstalled oclint
# 检查有没有 sonar-project.properties 文件 if [ ! -f sonar-project.properties ]; then echo >&2 "ERROR - No sonar-project.properties in current directory"; exit 1; fi
if [ "$vflag" = "on" ]; then echo "Xcode workspace file is: $workspaceFile" echo "Xcode application scheme is: $appScheme" echo "Xcode sources is: $srcDirs" fi
# 检查必须参数 if [ ! "$workspaceFile" != " " ]; then echo >&2 "ERROR - sonar.objectivec.project parameter is missing in sonar-project.properties. You must specify which projects (comma-separated list) are application code within the workspace $workspaceFile." exit 1 fi
if [ -z "$srcDirs" -o "$srcDirs" = " " ]; then echo >&2 "ERROR - sonar.sources parameter is missing in sonar-project.properties. You must specify which directories contain your .h/.m source files (comma-separated list)." exit 1 fi
if [ -z "$appScheme" -o "$appScheme" = " " ]; then echo >&2 "ERROR - sonar.objectivec.appScheme parameter is missing in sonar-project.properties. You must specify which scheme is used to build your application." exit 1 fi
## SCRIPT
# Create sonar-reports/ for reports output
if [[ ! (-d "sonar-reports") && ("$nflag" != "on") ]]; then if [ "$vflag" = "on" ]; then echo 'Creating directory sonar-reports/' fi mkdir sonar-reports if [[ $? != 0 ]] ; then stopProgress exit $? fi fi
export LC_ALL="en_US.UTF-8" if [[ "$workspaceFile" != "" ]] ; then echo "xcodebuild clean" xcodebuild clean -workspace "${workspaceFile}" -scheme "${appScheme}" echo "xcodebuild analyze" xcodebuild -workspace "${workspaceFile}" -scheme "${appScheme}" -configuration Debug analyze COMPILER_INDEX_STORE_ENABLE=NO | tee xcodebuild.log | xcpretty -r json-compilation-database else echo "no workspaceFile" exit 1 fi
ERROR: Error during SonarQube Scanner execution ERROR: Failed to upload report - 500: An error has occurred. Please contact your administrator
查看web.log
1
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (54581962 > 20971520). You can change this value on the server by setting the max_allowed_packet' variable.