Run sonarQube in CICD (CodePipeline on AWS)

Hello I want to run sonnarQube in my cicd (in AWS codePipeline)
here’s a code I found to run sonarQube on my java project

cd /testjava      #my project src dir
sonarQube='sonarqube-8.1.0.31237',
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.1.0.31237.zip
unzip ./sonarqube-8.1.0.31237.zip
# Set up non-root user to run SonarQube
groupadd sonar
useradd -d sonarqube-8.1.0.31237/ -g sonar -s /bin/bash
chown -R sonar:sonar sonarqube-8.1.0.31237/
sed -i 's/#RUN_AS_USER=/RUN_AS_USER=sonar/g' sonarqube-8.1.0.31237/bin/linux-x86-64/sonar.sh
sh $sonarQube/bin/linux-x86-64/sonar.sh start
# Get SonarScanner and add to PATH
sonarScanner='sonar-scanner-cli-4.2.0.1873-linux'
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/$sonarScanner.zip
unzip ./$sonarScanner.zip
export PATH=$PATH:$sonarScanner.zip/bin
mvn sonar:sonar

but it fails with an error:

"useradd: invalid home directory 'sonarqube-8.1.0.31237/." 

(and of course the directory is exists)

anyone can share a code that works? a very basic sonarQube scan on src directory in CICD pipeline…
Thank you

Hi,

Welcome to the community!

SonarQube 8.1 is woefully out of date at this point. More than 2 LTS releases behind. You should be targeting SonarQube 9.9 LTS, announced on the 7th instead.

The next step: for production the SonarQube server should run on a different host than analysis runs on. Get SonarQube up and running, and then look at setting up analysis.

 
HTH,
Ann