CCNet Make Version Configurable - cruisecontrol.net

I am automating build with CCNEt. The last step of the build is to create a file. Its name will be in the formatAS_V_1.0.0.1_DD_MMM_YYY. 1.0.0.1 is the version number. This version number will be used in multiple multiple projects. So I want this to be a configurable parameter. How can I do that?

What you want is to define a parameter in your CCNET configuration. I wrote about CCNET parameters a while ago.
Essentially, you can define your parameter using
<cb:define KEY=”VALUE” />
and then use the parameter using $(Key)
Example:
<cb:define Version="1.0.0.1" />
and then specify you label as AS_V_$(Version)_DD_MMM_YYY

Related

groovy RESTClient is not working on Windows 7 machine

I am trying to use the below lines to get API response, but its not working for me.
Please help me.
Groovy ver = 2.4.15
OS = windows 7
#Grab(group='org.codehaus.groovy.modules.http-builder',module='http-builder',version='0.7.1')
import groovyx.net.http.HTTPBuilder
As mentioned in the comments, I think the best place to start would be to run your script with the following flag turned on:
~> groovy -Dgroovy.grape.report.downloads=true <yourscript>
that should give you some logging indicating what the grape resolution is doing and hopefully where it tried to download the file from when it failed.
For an overview of the grape resolution mechanics, you can refer to the groovy documentation on grapes.
My guess is that groovy is trying multiple resolvers (i.e. maven central, jcenter, etc) and one of them is failing early even though a later one has the artifact. In a situation like this the resolution engine naturally should keep trying until it finds a working artifact but I have seen things fail this way before.
To modify the resolution order and behavior, you should look at the file:
<your user home dir>/.groovy/grapeConfig.xml
where, if the file does not exist, groovy uses the following default data for the file:
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="true">
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>
<ibiblio name="localm2" root="file:${user.home}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<ibiblio name="jcenter" root="https://jcenter.bintray.com/" m2compatible="true"/>
<ibiblio name="ibiblio" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
(from the groovy github repo)
Two things to note here:
The returnFirst attribute. The resolution engine will try the resolvers one by one and return the first hit for this specific artifact. If my hunch is correct, this is not working correctly and an early resolver is failing and not giving a later resolver a chance to resolve the artifact.
The list of resolvers is ordered so changing this order will affect the result.
So, long story short: turn on debugging and see if that gives anything.
Then either modify or create the grapeConfig.xml file and either:
change the order of the ibiblio elements to change the resolution order
add another maven resolver (i.e. add another ibiblio node) for a target you have verified has the artifact (and add it first in the chain to make sure one of the others does not fail first).
or play with the returnFirst flag to see if setting it to false resolves your issue

Conditional force build publisher CCnet fails

I have two build projects. lets call them project A and project A.pack. When I force build project A it asks me for Boolean parameter if I want to build project A.pack.
But I can't make in publishers block of project A a correct way to force build the project A.pack. I use conditional task but it doesn't work. In log file ccnet writes only that it fails on conditional task. What a usual way to do this in ccnet?
Update:
Sorry for my English. It's not my first language.
What I wanted to do is this:
In project A I added Boolean parameter:
<booleanParameter>
<name>ExampleParam</name>
<true name="Yes">1</true>
<false name="No">0</false>
<display>Example Param</display>
<default>No</default>
<required>false</required>
</booleanParameter>
And added conditional forcebuild in publishers like this:
<publishers>
<!-- some other tasks .. -->
<conditional>
<conditions>
<compareCondition>
<value1>${ExampleParam}</value1>
<value2>1</value2>
<evaluation>equal</evaluation>
</compareCondition>
</conditions>
<tasks>
<forcebuild>
<project>A.pack</project>
<serverUri>tcp://localhost:21235/CruiseManager.rem</serverUri>
</forcebuild>
</tasks>
</conditional>
</publishers>
When I press "force" it asks me for "Example Param", I check "Yes" and when it finishes building dashboard says that build was succesful but ForceBuildPublisher task failed.
There is no information in server log about why force build task failed.
It's CruiseControl.NET-1.6.7
Update 20150808:
I convinced my colleagues to update CCnet. In version 1.8.5 it's possible to do a conditional build like I wrote.
If the boolean parameter is true then write to a file that A.pack watches. A.pack builds if the file gets dirty. See Filesystem Source Control Block for use by A.pack in listening to the file made dirty by A.

Can I use an environment variable in Obfuscar config file?

The obfuscar config file needs to specify "InPath" and "OutPath". Is it possible to use an environment variable? If yes, how?The reason is that this config file is in SVN and then should be used by people having their projects locally in different locations where the environment variable points to.
e.g.
<Var name="InPath" value="%MYDEVPATH%\Project\bin\Release" />
instead of
<Var name="InPath" value="c:\foo\foo\foo\Project\bin\Release" />
regards,Tobi
edited: changed $(MYDEVPATH) to %MYDEVPATH%
It is impossible yet. Obfuscar does not attempt to evaluate environment variables.
I can create a work item to track this request and let you know once it is implemented.
Updated:
Fixed in https://github.com/lextm/obfuscar/commit/97eaa12ac75b2246bba64dd74752caa635ef8f7a
Should be part of vNext.

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>

cc.net dynamic parameters in publisher block

I am Using CC.Net to run an .exe file after project build is complete and need to pass the project name, publish date/time and user on the command line as parameters to the .exe. However I can't get cc.net to recognise these a dynamic properties and replace them with the correct values.
<publishers><exec executable="C:\MyApp.exe"></exec><buildArgs>"$[$CCNetProject]" "$[$CCNetBuildDate]" "$[$CCNetBuildTime]" "$[$CCNetUser]"</buildArgs><buildTimeoutSeconds>30</buildTimeoutSeconds></publishers>
The correct syntax for properties in ccnet config is $[CCNetProject]
I believe the correct syntax for properties in ccnet config is:
$[CCNetProject]
Rather than:
$[$CCNetProject]

Resources