複数の環境で実行する必要があるプロジェクト用の Cruisecontrol ビルドをセットアップしました。これは私が現在使用しているものです:
<parameters>
<selectParameter>
<name>Environment1</name>
<display>Environment1</display>
<allowedValues>
<value name="No">No</value>
<value name="Yes">Yes</value>
</allowedValues>
</selectParameter>
<selectParameter>
<name>Environment2</name>
<display>Environment2</display>
<allowedValues>
<value name="No">No</value>
<value name="Yes">Yes</value>
</allowedValues>
</selectParameter>
<selectParameter>
<name>Environment3</name>
<display>Environment3</display>
<allowedValues>
<value name="No">No</value>
<value name="Yes">Yes</value>
</allowedValues>
</selectParameter>
</parameters>
<conditional>
<conditions>
<compareCondition value1="Environment1" evaluation="equal" value2="Yes" />
</conditions>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>$[DirectoryOfBuildScript]</workingDirectory>
<projectFile>MSBuild.proj</projectFile>
<buildArgs>/v:n /p:Environment=Environment1;Version=$[BuildVersion];</buildArgs>
<targets>Deploy</targets>
<timeout>3000</timeout>
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\webdashboard\bin\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
</conditional>
<conditional>
<conditions>
<compareCondition value1="Environment2" evaluation="equal" value2="Yes" />
</conditions>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>$[DirectoryOfBuildScript]</workingDirectory>
<projectFile>MSBuild.proj</projectFile>
<buildArgs>/v:n /p:Environment=Environment2;Version=$[BuildVersion];</buildArgs>
<targets>Deploy</targets>
<timeout>3000</timeout>
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\webdashboard\bin\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
</conditional>
<conditional>
<conditions>
<compareCondition value1="Environment3" evaluation="equal" value2="Yes" />
</conditions>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>$[DirectoryOfBuildScript]</workingDirectory>
<projectFile>MSBuild.proj</projectFile>
<buildArgs>/v:n /p:Environment=Environment3;Version=$[BuildVersion];</buildArgs>
<targets>Deploy</targets>
<timeout>3000</timeout>
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\webdashboard\bin\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
</conditional>
ご覧のとおり、すべての条件文で異なるのは環境名だけです。選択した環境名をループしてビルド呼び出しを一般化する方法はありますか (バージョンは異なりません)。このようなもの:
// Conceptually I want a for loop which iterates through the selected environments
foreach(environmentName in selectedEnvironments)
{
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>$[DirectoryOfBuildScript]</workingDirectory>
<projectFile>MSBuild.proj</projectFile>
<buildArgs>/v:n /p:Environment=environmentName;Version=$[BuildVersion];</buildArgs>
<targets>Deploy</targets>
<timeout>3000</timeout>
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\webdashboard\bin\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
}