Search code examples
sonarqubegoogle-compute-enginebitnamigoogle-cloud-buildsonarscanner

Error "Could not find 'java' executable in JAVA_HOME or PATH" while installing sonar-scanner with sonarqube google compute instance


I've been trying to configure sonarqube to work with cloud build trigger and want to use bitnami's sonarqube compute instance installation but when I installed sonar-scanner using this guide: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ and when run sonar-scanner -h I receive this Error "Could not find 'java' executable in JAVA_HOME or PATH" my JAVA_HOME is opt/bitnami/java and PATH is opt/bitnami/java/bin help me what I'm doing wrong or if missing something.


Solution

  • Bitnami developer here,

    The following commands worked for me on a GCE instance:

    • Download solr-scanner 4.2.0:

    • Unzip it in /opt:

    sudo unzip -d /opt sonar-scanner-cli-*.zip
    
    • Download sonar-scanning-examples:

    • Unzip them in $HOME/sonar-scanning-examples:

    unzip -d $HOME master.zip
    cd /home/bitnami/sonar-scanning-examples-master/sonarqube-scanner
    
    • Analyze a project as shown below. Replace the PASSWORD placeholder with the correct password.
    /opt/sonar-scanner-*/bin/sonar-scanner -Dsonar.login=admin -Dsonar.password=PASSWORD
    

    In case you face some issue, try to load the environment before analyzing the project:

    sudo /opt/bitnami/use_sonarqube
    

    I hope it helps