Skip to content

Instantly share code, notes, and snippets.

@WillNilges
Last active July 17, 2020 15:40
Show Gist options
  • Save WillNilges/80a9854890722d0e1e86d5af5dc3c079 to your computer and use it in GitHub Desktop.
Save WillNilges/80a9854890722d0e1e86d5af5dc3c079 to your computer and use it in GitHub Desktop.
Download and "Install" SonarQube tools in your environment for C code analysis.
set -e # Stop the script if something fails.
#URL to your SonarQube instance
SONAR_INSTANCE=
if [ -z "$SONAR_INSTANCE" ]; then
echo "REMEMBER TO SET THE SONAR INSTANCE, FOOL!"
exit 1
fi
# In case you haven't gotten the SonarQube tools before...
if [ ! -d ~/sonar-stuff ]; then
build_dir=$(pwd)
cd ~/
mkdir sonar-stuff && cd sonar-stuff
# Grab the build wrapper (for C projects) and sonar-scanner (for analysis),
# unzip them into ~/sonar-stuff. These URLs will have to be updated now and again.
wget http://$SONAR_INSTANCE/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip
unzip sonar-scanner-cli-4.4.0.2170-linux.zip
cd $build_dir
fi
# I find that it's easiest to just add this stuff to the PATH.
echo "$PATH" | grep -q '~/sonar-stuff/build-wrapper-linux-x86' || export PATH=$PATH:~/sonar-stuff/build-wrapper-linux-x86
echo "$PATH" | grep -q '~/sonar-stuff/sonar-scanner-4.4.0.2170-linux/bin/' || export PATH=$PATH:~/sonar-stuff/sonar-scanner-4.4.0.2170-linux/bin/
#Okay, cool. Now build and analyze the repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment