Skip to content

Instantly share code, notes, and snippets.

@Thecarisma
Last active August 22, 2023 13:08
Show Gist options
  • Save Thecarisma/74cfdcf7818e9a17b6448919d4a11c2f to your computer and use it in GitHub Desktop.
Save Thecarisma/74cfdcf7818e9a17b6448919d4a11c2f to your computer and use it in GitHub Desktop.
Script to setup sonar-scanner on a Linux computer
#!/bin/sh
SONAR_QUBE_HOST="$1"
if [[ "$SONAR_QUBE_HOST" == "" ]];
then
SONAR_QUBE_HOST=http://34.89.91.40:9000
fi
# download and install sonar-scanner
apt-get update
apt-get install unzip wget -y
mkdir /downloads/sonarqube -p
cd /downloads/sonarqube
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
unzip sonar-scanner-cli-4.2.0.1873-linux.zip
mv sonar-scanner-4.2.0.1873-linux /opt/sonar-scanner
# configure sonar host and configuration
echo sonar.host.url=$SONAR_QUBE_HOST>/opt/sonar-scanner/conf/sonar-scanner.properties
echo sonar.sourceEncoding=UTF-8>>/opt/sonar-scanner/conf/sonar-scanner.properties
cat /opt/sonar-scanner/conf/sonar-scanner.properties
# add sonar-scanner to PATH
echo \#/bin/bash\\nexport PATH="\$PATH:/opt/sonar-scanner/bin">/etc/profile.d/sonar-scanner.sh
cat /etc/profile.d/sonar-scanner.sh
# load new PATH variable
. /etc/profile.d/sonar-scanner.sh
@Thecarisma
Copy link
Author

Thecarisma commented Aug 22, 2023

To install sonar-scanner from the sh terminal with the script

curl https://gist.githubusercontent.com/Thecarisma/74cfdcf7818e9a17b6448919d4a11c2f/raw/7c4c7144191136b87fd2bce8ce286d896c792c9e/install_sonar_scanner.sh -o install_sonar_scanner.sh
sh install_sonar_scanner.sh http://34.89.91.4:9000

From URL

sh <(curl -s https://gist.githubusercontent.com/Thecarisma/74cfdcf7818e9a17b6448919d4a11c2f/raw/7c4c7144191136b87fd2bce8ce286d896c792c9e/install_sonar_scanner.sh) http://localhost:9000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment