Calling .bat file from specific location with CCNET - cruisecontrol.net

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

Related

Cmakefiles missing after code coverage execution

I am trying to generate code coverage report using LCOV in Ubuntu platform. I referred
https://github.com/QianYizhou/gtest-cmake-gcov-example
It is working.
I am giving cmake --build ../application/build --target install in my shell script.
After script execution, I can see that the cmakefiles are generated in the build folder.
cd build && make test
cd build && make coverage_TEST_NAME //To check the coverage
I did execute above in my build folder and I generated report.
My problem is, I use this in gitlab pipeline. There is no build folder I can see. So I don't know how to do make coverage_TEST_NAME in my yml file
Generate code generation output in gitlab pipeline.
Problem resolved. Just like in my Ubuntu virtual machine, the application folder was there in my docker image.
I just added a ../application/build command in my yml script, it navigated there.

Calling groovy execute cross platform

I am currently using gmaven plus to run a groovy command inside maven.
The command (for the sake of example) would be
git help
If I run it on linux I can do:
'git help'.execute().text.trim()
This however doesn't work on windows. Instead I need to do:
'cmd /C git help'.execute().text.trim()
Is there a cross platform way of doing this?
Seeing that it worked for others got me thinking and indeed the problem was with my own PATH configuration;
Apparently, if you define git in the path as follows:
"C:\Program Files (x86)\Git\bin"
then when running from command it will find git. However, groovy will NOT find it.
On the other hand, if you define git in the path as follows:
C:\Program Files (x86)\Git\bin
i.e. without the "". Then everything works fine.
see also https://serverfault.com/questions/349179/path-variable-and-quotation-marks-windows

How to provide path to node_modules to ant <exec> to run node

I want to make an ant target to run nodejs command, but I am not aware how can I provide the path to node_modules at run time. I am trying something like this.
<exec executable="${env.NODE_HOME}/node" >
<env key="PATH" value="relative_path_to_node_modules}" />
<arg value="parameter"/>
</exec>
Actually, needed to update environment variable NODE_PATH. In my opinion, node search for this particular env variable.

CCNet Take Installation from Multiple svn

I am going to automate our setup creation activity. For these I need to get 3 items from 3 different svns
a. application binaries from https://productvss:8443/svn/Connect200/branches/Release_5.0.0.0
b. logger binaries from https://productvss:8443/svn/Logger/branches/Release_2.4.7
c. License binaries from https://productvss:8443/svn/licensing/branches/Release_2.4
What is the best way for getting the files in CCNet? source code block or something else.
Assuming you are triggering the builds with something other than listening for changes on these repositories I would use Nant's exec task with the SVN command line tool to get the files.
<exec program="svn.exe">
<arg line="co https://productvss:8443/svn/Connect200/branches/Release_5.0.0.0 <local_wc_directory>"/>
</exec>
same idea for the other two repositories...
Or you can create a small SVN project with only externals to your different projects path.
So When CC.NET do a checkout, it will get all the structure from different SVN path/Repo.
http://svnbook.red-bean.com/en/1.0/ch07s03.html

Cruisecontrol.net nant results different from non-cc.net

I've a nant script that builds a VS2008 solution. When I run it myself by typing 'nant' in the command line all the correct DLLs are copied to the respective bin directories. But when Cruisecontrol performs the CI build no DLLs are copied to the bin directories.
Any ideas what's causing this?
Your problem, dear Mr. Flibble, is that you have specified "test" as the target in the cc.net config which is overrigind the default target (build) that gets executed when executing nant from the commandline.
Very probably there is something in your environment not in the Cruise Control environment. Add something in the CruiseControl build (like setting verbose on nant) and confirm you have the same paths set up.

Resources