Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    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

    Scheduled Pinned Locked Moved Support
    variablesbuildmaster
    4 Posts 2 Posters 7 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jharbison
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          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;

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            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.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation