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!

Usage of Server and Environment variables



  • I'm trying to use variables defined in Admin->Environments or Admin->Servers. When the variable is defined in one of these sections and then I'm trying to use it in one of the powershell scripts as Ambient Variable - script doesn't recognize it.

    E.g. I defined a variable for one of the Environments as EnvCode = DEV1. Then in one of the scripts in Script Repository I define Ambient Variable and for its value I use $EnvCode, similar how I would use built-in variable like $ReleaseNumber. When script is running instead of actual $EnvCode value "DEV1" it just sees it as literal "$EnvCode".

    What would be the correct usage of Environment or Server variables? Can I use them in scripts at all? If not - where and how can they be used?

    Thanks

    Product: BuildMaster
    Version: 4.9.7



  • Hello,

    I was not able to reproduce this. Here is what I did.

    1. Create a new PowerShell Asset...

      • Name: Test Script
      • Parameters: none
      • One ambient variable: MyEnvVar ==> $EnvVar
      • Contents : Write-Host My var is $MyEnvVar;
    2. Create a variable on MYSERVER: $EnvVar = my server var

    3. Create a new application with a deployment plan that has a single action (targeting MYSERVER) that calls Test Script

    4. Output is My var is my server var, as expected

    I also deleted $EnvVar from the server, and then created it on an environment the server is associated with, and it works as expected.

    When I deleted $EnvVar from the environments, it produced the literal output (My var is $MyEnvVar) upon running.

    So, my guess is there's a typo somewhere...

    best,

    Alana



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation