Use tstamp property in tasks in a project - cruisecontrol.net

Can I use tstamp property BuildDate in a nant task to an xecutable task in cruise control net as given below? if that is possible, Is my usage correct?
<tstamp property="BuildDate" pattern="dd-mmm-yy" verbose="true" />
<exec executable="C:\WINDOWS\system32\cmd.exe">
<buildArgs>/C rename "D:\Disk Images\Disk1" ICE_$(BuildDate)"</buildArgs>
<buildTimeoutSeconds>10</buildTimeoutSeconds>
</exec>

Taking a first look everything looks fine so far... except for this: Use curly braces when accessing the property. So it's Disk1" ICE_${BuildDate}" instead of Disk1" ICE_$(BuildDate)".
UPDATE: Wait a minute... You're trying to pass the property back from NAnt to CCNET? No, that won't work. You may use the BuildDate property inside NAnt only.

A cumbersome way to achieve this would be to write your values into a xml file using nant, and then use the modificationReader task.

Related

How to get public folder absolute path in Shopware 6?

I'm trying to get a public folder path in shopware 6 in order to create a directory inside using the filesystem. Does anyone have an idea about it?
You could have a look at the service
shopware.filesystem.public which is defined in
vendor/shopware/core/Framework/DependencyInjection/filesystem.xml as
<service class="League\Flysystem\FilesystemInterface" id="shopware.filesystem.public" public="true">
<factory service="Shopware\Core\Framework\Adapter\Filesystem\FilesystemFactory" method="factory"/>
<argument>%shopware.filesystem.public%</argument>
</service>
When you inject this service, you can call
$publicFileSystem->createDir('folder')
to create your folder.
That does not exactly answer the question on how to get the path - but you usually don't need that, as you woult not interact directly with the filesystem, but via Flysystem classes instead.
If you really need the path, you could try something like
$publicFileSystem->getMetaData('.')['path']
This is untested by me and as written before, you might just not need the path. Also keep in mind, that the underlying filesystem might not even be a local storage.
Maybe not exactly bulletproof, but most of the time you can also use getcwd();
https://www.php.net/manual/en/function.getcwd.php
I mostly use it for writing debug-files like error_log(print_r($data, true)."\n", 3, getcwd().'/error.log');

Is there any way to run an individual test method in groovy?

I'd like to run an individual test method instead of the entire test class in Groovy on the cli - is this possible?
So instead of all the test methods in MyTestClass, I'd like to run just the testArbitrary method in MyTestClass.
Any help appreciated.
In Intellij Idea you could create run configuration, that will start single test method. Command will be copied to output panel and will look like so
com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit3 package.TestClass,testMethod
Like this, you can create your custom JUnitStarter class as described here https://stackoverflow.com/a/9288513/1601606
Natively, there is no such class, but it's pretty simple to create it.

CruiseControl.Net Modification Reader Example?

Does anyone have any example of how to use modification reader task?
Ok, I use this over XML:
<modificationReader>
<filename>mods.xml</filename>
<path>path/to/my/file/</path>
</modificationReader>
then, what? How do I get the information in "mods.xml" and use it?
Thanks
This appears to be used with the modificationWriter task which writes the modifications to a file (in the artifact directory by default).
http://build.sharpdevelop.net/ccnet/doc/CCNET/Modification%20Writer%20Task.html
If you're just trying to read in the modifications in to a different projects' buildLog, the above - with a path to the first project - should be sufficient.
Are you trying to do something different?
CruiseControl.NET: Build subproject obtained by SVN

Can I specify multiple possible sources for a ccnet statistic?

I have some builds that use NCover for test coverage analysis, and some that use DotCover. I merge the NCover/DotCover summary report into the ccnet log, but the item that I need to pull out into the ccnet "Coverage" statistic is different depending on the tool (because the format of the reports are different).
For NCover, I use the following:
<statistics>
<statisticList>
<firstMatch name="Coverage"
xpath="//coverageReport/project/#coverage"
generateGraph="true" />
</statisticList>
</statistics>
For DotCover, I need this:
<statistics>
<statisticList>
<firstMatch name="Coverage"
xpath="//Root/#CoveragePercent"
generateGraph="true" />
</statisticList>
</statistics>
Is there any way to specify both? If I just list both sections inside the statisticList, the second one always wins (so if I list DotCover second, builds that use NCover have their coverage stat set to zero, because the DotCover stat can't be found). What I want is for the stat to get set to the NCover stat if it exists, or to the DotCover stat if it exists.
Thanks for the help!
You might be able to do an OR in the xpath expression, for example:
<statistics>
<statisticList>
<firstMatch name="Coverage"
xpath="//Root/#CoveragePercent | //coverageReport/project/#coverage"
generateGraph="true" />
</statisticList>
</statistics>

CruiseControl.NET : launch build on commit

I searched a lot but i didn't find a solution for my problem.
I use CruiseControl.NET (1.4.4). My project (in ccnet.config) load a repository from a cvs server to a local repository, and launch some executables (msbuild, NUnit...).
I use a trigger (Interval or Schedule Trigger), that launch regularly my project. But if my project has not been modified, it always launch all next tasks. And I would like to avoid it. So i want to launch my project only if a commit has been detected.
Is there any solution for it please?
Thanks
Olivier
Your trigger needs to specify IfModificationExists:
<intervalTrigger
name = "dave"
seconds = "30"
buildCondition = "IfModificationExists" />
Although buildCondition="IfModificationExists" is the default anyway, so as long as its not set to ForceBuild you should be fine.
EDIT:
The URL Trigger might be of some use to you. You can set your svn server to modify a page on commmit and the CC.Net checks the page to see if it has changed, thus not getting all the files.
I start my project as below, which ensures that the tasks get executed only if there are modifications.
Hope this helps,
Anders, Denmark
Edited: My code excerpt didn't make it to the page - I've tried to replace less-than, bigger-than with brackets.
[project name="SpilMerePool" queue="Q2" queuePriority="1"]
[sourcecontrol type="svn"]
[trunkUrl]https://ajf-ser1.ajf.local:8443/svn/SpilMerePool/trunk[/trunkUrl]
[workingDirectory]c:\from_vc\SpilMerePool[/workingDirectory]
[executable]C:\Program Files\VisualSVN Server\bin\svn.exe[/executable]
[username]username[/username]
[password]password[/password]
[/sourcecontrol]
Just use IntervalTrigger, like this:
<triggers>
<intervalTrigger />
</triggers>
You can also add an modificationDelaySeconds, to wait for a number of seconds before starting the build after the last commit.
<modificationDelaySeconds>30</modificationDelaySeconds>
Thank you Anders Juul abd Andy for your quick answers.
By using the intervalTrigger with "IfModificationExists" build condition, the project must be loaded each time (it's logical ^^). But my project size is about 450Mo. So it's a little long.
So my last question is : can we execute all builds and next tasks when a commit command has been detected? (without loading all files, in CruiseControl).
I use TortoiseCVS (version 1.10.10). Maybe we can force CruiseControl project to be lauched after a commit?

Resources