Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

sonarqube - 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).

question from:https://stackoverflow.com/questions/65945460/gitlab-ci-sonar-scanner-the-term-sonar-scanner-is-not-recognized-as-the-nam

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...