'SONAR_HOST_URL not reachable in bitbucket pipeline sonarqube

I am trying to integrate the sonarqube to bitbucket pipeline, and have following code there

 - pipe: sonarsource/sonarqube-scan:1.0.0
              variables:
                SONAR_HOST_URL: ${SONAR_HOST_URL}
                SONAR_TOKEN: ${SONAR_TOKEN}
            - pipe: sonarsource/sonarqube-quality-gate:1.0.0
              variables:
                SONAR_TOKEN: ${SONAR_TOKEN}

and I am getting error

SonarQube server [$SONAR_HOST_URL] can not be reached

I first tried setting localhost:9000, which is running at my local server, got this error, then I give website url, still getting same error,

what should I give SONAR_HOST_URL

Any help, Thanks,



Solution 1:[1]

SonarQube server [$SONAR_HOST_URL] can not be reached

means SONAR_HOST_URL is not defined in the CI environment. You want to use Repository settings -> Repository variables to add both host url & token (ensure Secured check box is set for token).

P.S. The host url should be publicly accessible. It won't work for localhost:9000 because the Bitbucket CI has not\ way to connect to the instance of the sonarqube server running on your local dev box.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Artur Bakiev