I have setup Sonar and want to run the code analysis as part of my nightly build.

I've setup the nightly build but I'm having some issues with running the sonar runner.

To run code analysis I want to navigate to a folder I've created called \BuildAssets, inside the main solution folder. To run the code analysis manually I would open up a command prompt within \BuildAssets and run: %SONAR_RUNNER_HOME%\Bin\sonar-runner.bat

How would I set this up in CCNET?

I've tried:

<exec> 
  <executable>%SONAR_RUNNER_HOME%\bin\sonar-runner.bat</executable>
  <baseDirectory>BuildAssets</baseDirectory>
  <buildTimeoutSeconds>$(slowBuildTimeout)</buildTimeoutSeconds>
</exec>

but this doesn't work because it tries to run c:\cc\myBuild\code\BuildAssets\%SONAR_RUNNER_HOME%\bin\sonar-runner.bat

I also tried:

<exec> 
  <executable>cmd</executable>
  <baseDirectory>BuildAssets</baseDirectory>
  <buildArgs>%SONAR_RUNNER_HOME%\bin\sonar-runner</buildArgs>
  <buildTimeoutSeconds>$(slowBuildTimeout)</buildTimeoutSeconds>
</exec>

but this doesn't seem to do anything either. I'm sure it's pretty easy but I'm not well versed in CCNET configuration.

有帮助吗?

解决方案

I was missing the /C from the build args element, so I got this working with:

<exec> 
  <executable>c:\Windows\System32\cmd.exe</executable>
  <baseDirectory>BuildAssets</baseDirectory>
  <buildArgs>/C %SONAR_RUNNER_HOME%\bin\sonar-runner</buildArgs>
  <buildTimeoutSeconds>$(slowBuildTimeout)</buildTimeoutSeconds>
</exec>

其他提示

I suppose SONAR_RUNNER_HOME is the environment variable. If so, you should reference it like this: $(SONAR_RUNNER_HOME).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top