SonarQube not connecting with GitHub Actions

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) - 9.9.4.87374
  • how is SonarQube deployed: zip, Docker, Helm - zip
  • what are you trying to achieve - Trying to Run quality get check for my project
  • what have you tried so far to achieve this: - I am able to run quality get check via terminal from project directory but same fails in Git Actions with below error

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Error: SonarQube server [***] can not be reached

2037[INFO] ------------------------------------------------------------------------

2038[INFO] BUILD FAILURE

2039[INFO] ------------------------------------------------------------------------

2040[INFO] Total time: 19.865 s

2041[INFO] Finished at: 2024-05-21T17:39:11Z

2042[INFO] ------------------------------------------------------------------------

2043Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar (default-cli) on project mcProductService: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000: Connection refused → [Help 1]

2044Error:

2045Error: To see the full stack trace of the errors, re-run Maven with the -e switch.

2046Error: Re-run Maven using the -X switch to enable full debug logging.

2047Error:

2048Error: For more information about the errors and possible solutions, please read the following articles:

2049Error: [Help 1] MojoExecutionException - Apache Maven - Apache Software Foundation

2050Error: Process completed with exit code 1.

Hey there.

Can you share your GitHub Actions YML file?

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time

# For more information see: Building and testing Java with Maven - GitHub Docs

name: Build

on:
push:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles(‘**/pom.xml’) }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=mcProductService

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
  - name: Update dependency graph
    uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

Thanks!

And you’ve set the SONAR_HOST_URL variable appropriately?

Keep in mind this URL must be accessible from your GitHub Actions runner. If you’re using a hosted runner, it won’t be able to access localhost:9000 on your machine.

Thanks, this helps