Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Text Templating syntax
-
Hi Guys,
I am just looking at text templating and have a question.
I have the below template:
<% foreach $server in @ServersInRoleAndEnvironment(QCAD VAS, VT) { %>
<CadServer index="${index}" systemName="Vis${EnvironmentName}" serverAddress="" userPosition="${server}" userProfile="Administrator" userId="VIM${VIM_Number}ARL${index}" userPassword=""> </CadServer>
<% $Increment(${index}, 1); %>
<% } %>Where $index is set in the plan and passed into the text template function:
{
foreach $VimServer in @ServersInRoleAndEnvironment(QCAD VIM, VT)
{
for server $VimServer
{
set $index = 1;Apply-Template test-text-template ( AdditionalVariables: %(VIM_Number: ${VIM_Number}, index: ${index}), OutputVariable => $result ); Log-Debug $result; } }
}
And I believe it is having an issue with the index/increment as im getting:
Unhandled exception: System.ArgumentNullException: Value cannot be null. Parameter name: script at Inedo.ExecutionEngine.Parser.Compiler.<Validate>d__9.MoveNext() at System.Collections.Generic.List
1..ctor(IEnumerable
1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Inedo.ExecutionEngine.Templating.TextTemplate.Parse(TextReader reader) at Inedo.ExecutionEngine.Templating.TextTemplate.Parse(String s) at Inedo.BuildMaster.Windows.ServiceApplication.Executions.PlanExecuter.BuildMasterExecutionContext.ApplyTextTemplateAsync(String text, IReadOnlyDictionary
2 additionalVariables) at Inedo.Extensions.Operations.General.ApplyTemplateOperation.<ExecuteAsync>d__28.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Inedo.BuildMaster.Windows.ServiceApplication.Executions.PlanExecuter.DeploymentPlanExecuter.<Inedo-ExecutionEngine-Executer-IExecutionHostEnvironment-ExecuteActionAsync>d__25.MoveNext()If I remove all references to the index it does the rest fine.
Any thoughts where im going wrong?
Product: BuildMaster
Version: 5.8.1
-
Basically, the template doesn't represent valid OtterScript, and that's why there is an error. Basically, this is not a valid OtterScript statement:
$Increment(${index}, 1);
You can, however, do this:
set ${index} = $Increment(${index}, 1);
Except, the "set" statement is not supported in a text template, which means you cannot do what you're doing.
You could probably work something out with
$foreach $i in @Range(...)
, but it could get a little messy.