Welcome to OGeek Q&A 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...