Question

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.

Was it helpful?

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.

OTHER TIPS

The left side variables in your first cb:if expression need to be surrounded by single quotes, like you do in the second cb:if expression, like so:

  <cb:if expr="'$[Branch]' == 'QA' || '$[Branch]' == 'UAT'">
    <trunkUrl>$(SVNLocation)/$(ProjectSvnReleaseLocation)/$[Branch]</trunkUrl>
  </cb:if>
  <cb:else>
     <trunkUrl>$(SVNLocation)/$(ProjectSvnDevLocation)</trunkUrl>            
  </cb:else>

You are confusing two concepts here. cb:if is part of the preprocessor and is used when parsing the configuration, before any project is run. If you want to act depending on the value of a dynamic value, you should use the conditional task with a compare value condition :

http://www.cruisecontrolnet.org/projects/ccnet/wiki/Conditional_Task

http://www.cruisecontrolnet.org/projects/ccnet/wiki/Compare_Values_Condition

This will work when running a project, inside a task. However, for your case, this will not help because you want to change a value inside a source control block, which is not supported the way you want it. What you could do, though, is have the branch name as the value of the parameter :

http://www.cruisecontrolnet.org/projects/ccnet/wiki/SelectParameter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top