Search code examples
sonarqubegitlab-cigitlab-ci-runnersonar-runner

GitLab-CI: sonar-scanner : The term 'sonar-scanner' is not recognized as the name of a cmdlet, function,


I'm trying to add SonarQube to a local instance of GitLab-CI, but can't get past this error produced by GitLab-CI Runner:

Note: GitLab-Runner, Sonar-Scanner and SonarQube are all installed on the same Windows server.

enter image description here

My first thought was, it can't find the runner, installation/permission problem. So....

I have verified:

  • SonarQube Service run as Admin and has full access to Sonar-Scanner directory
  • GitLab Runner Service as Admin and has full access to Sonar-Scanner directory
  • Sonar-Scanner Installation double checked (Standalone executable: sonarscanner-for-msbuild) (installed per https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/ )
  • Sonar-Scanner added to Environment Variables' 'Path':

enter image description here

And still the same error so I tried running Sonar-Scanner on its own:

enter image description here

and that seems to run ok. But GitLab still produces the same issue. Maybe I'm using the wrong Sonar-Scanner?

I'm fairly new to GitLab-CI's Runner so any guidance/suggestions you can offer is greatly appreciated. Not sure where else to look (I've read everything/anything remotely related).


Solution

  • My issue was related to environment path. I have multiple accounts.

    • GitLab Runner Service as Admin and has full access to Sonar-Scanner directory

    The account that GitLab runner was using was not the account that had the environment variables. Once SonarScanner directory was added to the user environment variables (Path) of the GitLab runner windows account, it worked as expected.