Search code examples
emailconfigurationcruisecontrol.netusergroups

Email Group Configuration in CC.NET using a single config file


We have started using CC.NET for continuous integration and as the number of projects monitored builds up I would like configure the email alerts via a single config file.

What I mean by this is that I would like to have a list of the users in different groups in a single config file that is referenced by ALL the project configuration files:

<user name="user1" group="buildmasters" address="[email protected]"/>
<user name="user2" group="internalapplications" address="[email protected]"/>
<user name="user3" group="internalapplications" address="[email protected]"/>
<user name="user4" group="externalapplications" address="[email protected]"/>
<user name="user5" group="externalapplications" address="[email protected]"/>

Then the project configuration file will reference the correct group:

<group name="internalapplications" notification="change"/>

So for the different projects that are internal applications I would import the single config file then set the internal applications group. I would also like to add buildmasters for everything so that for now I can keep track of people if they are having problems.

This would mean I'd like to have a user in two or more groups for example but I don't know if it's possible:

<user name="user1" group="buildmaster, externalapplications" address="[email protected]"/>

I've been working under the assumption that one day I could configure this and have just a single file with all the users email addresses in, but today I've gone to do it and I'm not sure it works like this.

Can anyone describe how they have approached this?


Solution

  • What you want to do is use CC.Net Configuration Preprocessor

    I made an email.config

    <cb:define name="email-template" xmlns:cb="urn:ccnet.config.builder">
        <email from="[email protected]" mailhost="server" includeDetails="TRUE"
             mailhostUsername="buildadmin" mailhostPassword="pass">
          <users>
            <user name="dev" group="dev" address="[email protected]"/>
    
          </users>
          <groups>
            <group name="buildmaster" notification="always"/>
            <group name="developers" notification="always"/>
          </groups>
    
        </email>
    </cb:define>
    

    and included it where needed...

    <cruisecontrol xmlns:cb="urn:ccnet.config.builder">
    
        <cb:include href="C:\email.config" />
    
    <project name="MyProject" queue="Build" queuePriority="1" >
    
        <cb:email-template >
    
        </cb:email-template>
    
    </project>
    
    <project name="MyProject2" queue="Build" queuePriority="1" >
    
        <cb:email-template >
    
        </cb:email-template>
    
    </project>
    
    </cruisecontrol>