Search code examples
.netcruisecontrol.netccnet-configbuild-system

Using Conditional Parameters in CCNET version 1.8.2 to change svn locations


I am trying to setup a build server for our applications. When doing a force build I want to use parameters to determine what to build. Below I have the setup that will work DEV mainly because the if statement that Here is a snippet of the setup. It will always be false regardless if I pick QA or UAT. Has anyone tried to do this with cruisecontrol.net before?

<cb:define name="ParametersTemplate">
    <parameters>
      <selectParameter>
        <name>Target</name>
        <display>Target to Build</display>
        <description>Which target do you want to build?</description>
        <default>DEV</default>
        <allowedValues>
          <value name="DEV">DEV</value>
          <value name="QA">QA</value>
          <value name="UAT">UAT</value>
        </allowedValues>
      </selectParameter>
      <textParameter>
        <name>Branch</name>
        <display>Branch Name:</display>
        <description>Name of the branch you want to build?</description>
        <default>_DEV</default>
        <minimum>8</minimum>
        <maximum>255</maximum>
        <required>true</required>
      </textParameter>
    </parameters>
  </cb:define>

<cb:define name="ProjectTemplate">
    <workingDirectory>$(WorkingDir)\$(ProjectName)</workingDirectory>
    <artifactDirectory>$(ArtifactsDir)\$(ProjectName)</artifactDirectory>
    <sourcecontrol type="svn" cleanCopy="true">
      <workingDirectory>$(WorkingDir)\$(ProjectName)</workingDirectory>
      <cb:if expr="$[Branch] == 'QA' || $[Branch] == 'UAT'">
        <trunkUrl>$(SVNLocation)/$(ProjectSvnReleaseLocation)/$[Branch]</trunkUrl>
      </cb:if>
      <cb:else>
         <trunkUrl>$(SVNLocation)/$(ProjectSvnDevLocation)</trunkUrl>            
      </cb:else>
      <cb:SVNCredentials/>
    </sourcecontrol>
    <labeller type="svnRevisionLabeller">
      <cb:LabelCommon />
      <cb:if expr="'$[Branch]'=='QA' || '$[Branch]'=='UAT'">
        <url>$(SVNLocation)/$(ProjectSvnReleaseLocation)/$[Branch]</url>
      </cb:if>
      <cb:else>
        <url>$(SVNLocation)/$(ProjectSvnDevLocation)</url>
      </cb:else>
      <cb:SVNCredentials/>
    </labeller>
    <tasks>
      <nant>
        <targetList>
          <target>$(ProjectName)</target>
        </targetList>
        <cb:NantCommon />
      </nant>
    </tasks>
    <cb:ParametersTemplate/>
  </cb:define>

One thing that I looked up and found was replacement variables, but I am not sure exactly how I could utilize them in for a setup like this.

Any assistance would be greatly appreciated.


Solution

  • In my humble opinion, it's not a good idea to try and change the svn url like that. Even if you get it to work, various other things might break. I'd go with three different projects instead, using a common template to share the rest of the configuration.