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!

Maps/Lists do not work



  • I'm pulling my hair out trying to get some very basic iteration working using non-execution set variables (ie setting things at Global with potential to override at lower scope).

    Setting a $variable to some value works fine but I need to do something like...

                       foreach $DeployConfigKey in @MapKeys(%DeployConfigs)
                        {
                           ...
                        }
    

    So far I'm getting nowhere fast with execution errors saying "Invalid value for property Map; expected map."

    Further doing something like set %executionvar = %DeployConfigs complains that a map cannot be set by a scaler value.

    The variable, DeployConfigs looks like ...

    %{"Web.config": ["Web.Beta.config", "Web.Release.config"]}

    and is defined at Global scope.

    What am I doing wrong?

    Product: BuildMaster
    Version: 5.7.3


  • inedo-engineer

    Copying John's answer from StackOverflow:

    Maps are specified as %(key: value), here is an example plan that should help:

    set %map = %(Web.config: @("Web.Beta.config", "Web.Release.config"));
    
    foreach $key in @MapKeys(%map)
    {
        set @values = %map[$key];
        Log-Information `$key = $key;
        Log-Information `@values = $Join(", ", @values);
    }
    
    Sleep 3;
    


Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation