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
unzip ./
# Set up non-root user to run SonarQube
groupadd sonar
useradd -d sonarqube- -g sonar -s /bin/bash
chown -R sonar:sonar sonarqube-
sed -i 's/#RUN_AS_USER=/RUN_AS_USER=sonar/g' sonarqube-
sh $sonarQube/bin/linux-x86-64/ start
# Get SonarScanner and add to PATH
unzip ./$
export PATH=$PATH:$
mvn sonar:sonar

but it fails with an error:

"useradd: invalid home directory 'sonarqube-" 

(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


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.