Why it looks for [http://localhost:9000]

I’m trying to configure my Maven project for SonarCloud use in GitHub actions.
I have such errors when building on GitHub actions:
Error: SonarQube server [http://localhost:9000] can not be reached

Error: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project goods-partner: 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]

What could bed the reason of failure? why does it looks for http://localhost:9000 though I configured https://sonarcloud.io (see below)?

Here is sonar-cloud.yml:

name: Build
on:
  push:
    branches:
      - 76-sonarcloud-integration
  pull_request:
    types: [opened, synchronize, reopened]
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 SonarCloud 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:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

And here is pom.xml piece:

        <sonar.organization>some-text-here</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>        
        <sonar.projectKey>some-text-here</sonar.projectKey>

Are you sure you’ve set the configuration in your root pom.xml, and not one of the subprojects?

Hi Colin!
Yo`re right. Now this moved to parent pom.xml:

<sonar.organization>some-text-here</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>some-text-here</sonar.projectKey>

But another error occurs:

Please check if these other posts can resolve your issue. You are most likely encountering a problem with how you are defining Sonar analysis parameters of your multimodule project (as defined by the cleanAllWorkingDirs method calls):

This helped to solve my StackOverFlowError:

So I added <sonar.moduleKey>${project.artifactId}</sonar.moduleKey> to the root POM
Thank`s a lot for help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.