views:

397

answers:

3

Hi all,

I have various settings in my ccnet.config file and wish to pass them to my build file in order to keep these constants in one place.

How do I do that?!

Thanks,

Anders, Denmark

+1  A: 

Assuming your build file is a NAnt file, you would do it like this:

<nant>
    <buildFile>xx.build</buildFile>
    <buildArgs>-D:foo="$(foo)" -D:bar="$(bar)"</buildArgs>
    ...
</nant>

You can access the variable in the build script via ${foo} resp. ${bar} then.

The Chairman
A: 

Hi Chairman Tsetung,

Glad to see you alive and kicking ;-)

I probably should have been a bit more specific; below is an exerpt from my ccnet.config - I'm referring to the parameter value by a preprocessor block. I would expect, at the very least, that the variable side of the buildArg would appear in the log or something?! (I get error when referring to ${ccnetProject} in the build script).

<cb:define name="nant-build-block" >
<nant>
<executable>
<cb:pathToNant/>
</executable>
<buildArgs>-D:ccnetProject="$(ccnetProject)"</buildArgs>
<buildFile>
<cb:projectDirectory/>\$(buildFile)
</buildFile>
<targetList>
<target>
<cb:target/>
</target>
</targetList>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</nant>
</cb:define>

Anders Juul
I agree that indentation is for wimps ;-)
The Chairman
Anyway - the configuration looks o.k. on the first view. Perhaps it has got something to do with using ccnetProject as argument name. CCNET automatically passes CCNetProject as Integration Property to the NAnt script, i.e. the CCNET project name. Different casing but I know they have issues with that. Please try to rename the argument.
The Chairman
Guess I could look more into how stackoverflow allows formatting ;-) I tried to use the ccnet example as it is - <buildArgs>-D:build.Major=5 -D:build.Minor=4</buildArgs> To no avail - can't reference those either...
Anders Juul
So it's a more complicated problem. Please check the call to NAnt in your CCNET log file. You should see something like "Starting process [C:\nantdir\NAnt.exe] in working directory [C:\foo\working] with arguments [-nologo -buildfile:C:\scripts\xx.build -logger:NAnt.Core.XmlLogger -t:net-3.5 -v+ -D:foo="foo" -D:bar="bar" -D:CCNetArtifactDirectory="C:\foo\artifact" -D:CCNetBuildCondition=ForceBuild -D:CCNetBuildDate=2009-09-11 ... target1 target2]". Do you have the arguments there?
The Chairman
It took a while to debug - but you were right of course!Apparently the service will reload if ccnet.config changes (this is a good thing!), but in some cases errors in ccnet.config are not listed in ccnet.log, but will cause the ccservice to retain the last-good-configuration. In effect, ccservice was not running the configuration I thought it was, but my updated nant-build-files were re-read as exptected. This caused a mismatch where the values were not passed to build file. Thanks for helping out - greetings from the West ;-)
Anders Juul
By the way - the CCValidator helped me track the error in no time, once I fired it up
Anders Juul
Glad to hear it works now. Feel free to post any further questions regarding CCNET on SO. I'll read them with interest.
The Chairman
+1  A: 

There seems to be something wrong with your setup, because I'm using

<buildArgs>-D:publishroot="$(publish-directory)"</buildArgs>

and NAnt sees this as expected. Does the value of the variable contain spaces? I had problems with this before.

skolima