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!

    Combine strings BuildMaster

    Scheduled Pinned Locked Moved Support
    6 Posts 2 Posters 19 Views
    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.
    • A Offline
      ali.meigooni_1735
      last edited by

      Is it possible to combine 2 strings into 1 string (without using a separator character)?

      Specifically, I would like to merge the values of two variables into one.

      Thank you,
      Ali

      1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer
        last edited by

        Hi Ali,

        Sure, it would just be like $Variable2$Variable1 or ${Variable 2}${Variable 1}.

        Check out documentation on Strings & Values in OtterScript to learn more.

        1 Reply Last reply Reply Quote 0
        • A Offline
          ali.meigooni_1735
          last edited by ali.meigooni_1735

          Is it possible to use the result of combining two strings to call another variable?

          For example:

          set $BuildMaster_Test_1 = Test;
          set $Number = 1;
          Log-Debug "$(BuildMaster_Test_$Number)";

          In this example, I hoped it would output "Test". However, it actually outputs "BuildMaster_Test_1".

          1 Reply Last reply Reply Quote 0
          • atrippA Offline
            atripp inedo-engineer
            last edited by

            I think, you want to use $Eval function. Note that grave apostrophe (`) is an escape character.

            set $BuildMaster_Test_1 = Test;
            set $Number = 1;
            Log-Debug `$BuildMaster_Test_$Number;
            Log-Debug $Eval(`$BuildMaster_Test_$Number);
            

            So the output would be:

            $BuildMaster_Test_1
            Test
            
            1 Reply Last reply Reply Quote 0
            • A Offline
              ali.meigooni_1735
              last edited by ali.meigooni_1735

              Thank you! That information allowed me to get a lot further than before.

              At the very beginning of this script, the script separates into multiple threads using async. In each thread, the same variable is being set to different values. Will the values for each variable be contained within each respective thread? Or might they leak over into other threads?

              Thank you,
              Ali

              foreach $DeployableName in @BM_DeployableList
              {
                  with async = DeployableList
                  {
                      set $DeployPath = $Eval(`$BM_DeployPath_$DeployableName);
                      set $AppPoolName = $Eval(`$BM_AppPoolName_$DeployableName);
                      IIS::Stop-AppPool $($AppPoolName);
                      Delete-Files *
                      (
                          Directory: $DeployPath,
                          Verbose: true
                      );
                      Deploy-Artifact $DeployableName
                      (
                          To: $($DeployPath),
                          DoNotClearTarget: false
                      );
                      IIS::Start-AppPool $($AppPoolName);
                  }
                  await DeployableList;
              }
              
              atrippA 1 Reply Last reply Reply Quote 0
              • atrippA Offline
                atripp inedo-engineer @ali.meigooni_1735
                last edited by

                Nice OtterScript :)

                This will work, the variables won't "leak over" or anything like that.

                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