AWS CI/CD pipeline failed due for sonar scanner

I have setup sonarqube in aws instanace with version 8.9.1 and i able to access the portal.

and try to config ci/cd pipeline to get connect sonarqube for code review.

codebuild is getting failed below is error

COMMAND_EXECUTION_ERROR: Error while executing command: sonar-scanner \ -Dsonar.projectKey=Sales_Portal \ -Dsonar.sources=. \ -Dsonar.host.url=http://172.50.60.137:9000 \ -Dsonar.login=$LOGIN. Reason: exit status 1

in logs it shows error as below

ERROR: SonarQube server [http://172.50.60.137:9000] can not be reached

There is not connectivity issue b/w where code build server and sonarqube servers. it has communication
for your infor buildspec file

version: 0.2

env:
secrets-manager:
LOGIN: Sale_portal_SQ:SONAR_TOKEN

phases:
pre_build:
commands:
- echo Installing SonarQube Scanner
- curl --fail --location --retry 3 --silent https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip --output sonarscanner.zip
- unzip sonarscanner.zip -d /opt/sonarqube/
- export PATH=$PATH:/opt/sonarqube/sonar-scanner-4.8.0.2856-linux/bin/
build:
commands:
- echo Building app
post_build:
commands:
- echo Running SonarQube analysis
- sonar-scanner -Dsonar.projectKey=Sales_Portal -Dsonar.sources=. -Dsonar.host.url=http://172.50.60.137:9000 -Dsonar.login=$LOGIN

Hey there.

How did you confirm that there’s good communication between the build server and SonarQube?

It might be useful to add a curl step in your build to verify, like curl http://172.50.60.137:9000/api/system/health

HI,

i am gettign below error

root@ip-172-50-56-39 ec2-user]# curl http://172.50.60.137:9000/api/system/health
{“errors”:[{“msg”:“Insufficient privileges”}]}[root@ip-172-50-56-39 ec2-user]#

however i check only sq ip its connecting

curl http://172.50.60.137:9000/
<!doctype html>SonarQube*,:after,:before{margin:0;padding:0}body,html{background-color:#f3f3f3}body{overflow-y:scroll}fieldset,img{border:0}address,caption,cite,code,dfn,th,var{font-style:normal;font-weight:400}caption,th{text-align:left}q:after,q:before{content:“”}abbr,acronym{border:0;font-variant:normal}input,select,textarea{font-weight:inherit}button,input,select,textarea{font-family:inherit;font-size:inherit}textarea{min-height:40px}button::-moz-focus-inner,input::-moz-focus-inner,select::-moz-focus-inner{border:0;padding:0}legend{color:#000}code,kbd,pre,samp,tt{font-family:Consolas,Ubuntu Mono,Liberation Mono,Menlo,Courier,monospace;font-size:12px;line-height:18px}img,svg{vertical-align:top;overflow:visible}hr{margin:4px 0;padding:0;height:1px;border:none;background-color:#e6e6e6}body,html{color:#333}body{font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:13px;line-height:1.23076923}.h1,h1{line-height

Hi,

i am getting this error now
ERROR: Error during SonarScanner execution

2023-02-22T21:53:17.648+05:30 ERROR: Not authorized. Please check the properties sonar.login and sonar.password.

2023-02-22T21:53:17.648+05:30 ERROR:

2023-02-22T21:53:17.648+05:30 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

2023-02-22T21:53:17.648+05:30

2023-02-22T21:53:17.648+05:30 [Container] 2023/02/22 16:23:15 Command did not exit successfully sonar-scanner -Dsonar.projectKey=Sales_Portal -Dsonar.sources=. -Dsonar.host.url=http://172.50.60.137:9000 -Dsonar.login=$LOGIN exit status 2

2023-02-22T21:53:17.648+05:30 [Container] 2023/02/22 16:23:15 Phase complete: POST_BUILD State: FAILED

2023-02-22T21:53:17.648+05:30 [Container] 2023/02/22 16:23:15 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sonar-scanner -Dsonar.projectKey=Sales_Portal -Dsonar.sources=. -Dsonar.host.url=http://172.50.60.137:9000 -Dsonar.login=$LOGIN. Re

There’s a good chance like $LOGIN isn’t resolving to a SoanrQube token as you expect.