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!

Recursive Variable Evaluation



  • Is there a way to have variable expansion inside of another variable? It would be nice to be able to build up variables using other variables that are fully evaluated during execution.

    {
      "CommonPath": "\common\path",
      "SpecificPath1": "$CommonPath\specific\place\here",
      "SpecificPath2": "$CommonPath\another\place\there"
    }
    
    Log-Information $SpecificPath2;
    
    INFO:  \common\path\another\place\there
    

    Product: BuildMaster
    Version: 5.6.8



  • You can do this with the $Eval function:

    set $CommonPath = "\common\path";
    
    set $SpecificPath2 = "`$CommonPath\another\place\there";
    
    Log-Information $Eval($SpecificPath2);
    

    Note the escaped variable in $SpecificPath2 that prevents the initial expansion.

    Does that help?



  • Yes, thank you. This will work for my purposes although it is less than ideal having to litter $Eval statements throughout my plans. Also, when using properties set outside of a plan (e.g. application variables) this requires putting $Eval in the property definition

    {
      "CommonPath": "\common\path",
      "SpecificPath1": "$CommonPath\specific\place\here",
      "SpecificPath2": "$Eval($CommonPath)\another\place\there"
    }
    Log-Information $SpecificPath1;
    Log-Information $SpecificPath2;
    
    INFO: $CommonPath\specific\place\here
    INFO:  \common\path\another\place\there
    

    It would be nice to be able to always fully expand variables. I realize changes around variable expansion could cause regression issues for clients but perhaps having the ability to set a parameter that modifies how evaluation is handled in the current context would be manageable.

    set $VariableExpansion = Full;



  • We will implement this eventually once we have the specs nailed down. The plan is to offer a per-variable setting (in the same vein as the "sensitive" option) so it shouldn't break backwards compatibility.



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation