Search code examples
maveninputexecnantsonarqube

How to execute sonar command line in NAnt


I want to use NAnt to execute sonar to scan my C# code. The sonar command line is "mvn sonar:sonar", in which 'mvn' is the command name, 'sonar:sonar' is the user name and password. I tried two ways to execute it:

1.

<target name="buildOM" description="......">
    <exec program="mvn" workingdir="C:\codes\projects\helloworld">
        <arg value="sonar:sonar"/>
    </exec>
</exec>

2.

<target name="buildOM" description="......">
    <exec program="mvn sonar:sonar" workingdir="C:\codes\projects\helloworld">
    </exec>
</exec>

But these do not work. I found 'input' tag for Ant. "Ant : Passing username and password to exec". But I cannot find it in NAnt help document. I try to search the solution in the internet for 2 days, but failed.

Could you help me how to resolve it ? Thank you.


Solution

  • How about calling the command shell and running maven within it? Something like below...

    <target name="buildOM" description="......">
        <exec program="cmd.exe" workingdir="C:\codes\projects\helloworld">
            <arg value="/c mvn sonar:sonar"/>
        </exec>
    </exec>