Hi Chris,

At the moment CC.NET does not have anyway of setting variables at runtime,
the parameters were intended to be set externally (e.g. by a client) so we
didn't add any way of internally setting them.

However, since you are writing a custom labeller there is a hack you can use
to set an existing parameter. The IIntegrationResult has a property called
Parameters that exposes all the parameters for a project. So in the
Generate() method you could add some code like:

foreach (var parameter in integrationResult.Parameters)
{
    if (parameter.Name == "Internal")
    {
        parameter.Value = "The Value";
        break;
    }
}

The parameter will then be used in the normal way by the rest of the system.

Now for the caveats:
1. The parameter needs to be defined in the project definition - if it
doesn't it won't be in the Parameters property
2. Any users triggering a build will also see and set the parameter - but it
will be overridden by your labeller

I will see what we can do to make this easier in the next version of CC.NET.


Craig

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Christopher
Sent: Thursday, 18 November 2010 5:39 a.m.
To: ccnet-user
Subject: [ccnet-user] Setting variables at runtime

Hi,

I have a simple requirement where I want to publish my build into
subdirectories depending on the major and minor version of the build.
So for example, build version 2.3.0.1 goes into a subdirectory 2.3 and
2.4.0.1 goes into a directory 2.4. I have a custom labeller that sets the
CCNetLabel to equal the build version. I have also made a custom publisher
that strips the CCNetLabel and then creates the subdirectories, so far so
good.

The problem is, I want to use the resulting publish path (e.g: D:
\MyBuilds\2.3\2.3.0.1) in several tasks. How do I pass the new path string
that was created in my custom build publisher to other tasks?
Can I define variables that I can write to at runtime some how?

Chris


Reply via email to