Variables

A variable in BuildMaster is a special value that can change based on the current build or release. These variables may be used in your deployment plans as direct value substitutions in text fields, or you may use them to control which Action Groups execute.

Creating a Variable

To create a build-level variable in an Application, first click on "Settings" in the navigation menu, then "Manage Variables":

Application Variables

Clicking the "Create New Variable" page will allow you to select a variable type from a list of defined variable types.

Types of Variables

Dropdown List Constrained to a set of predefined values. (Example: value may be "yes" or "no")
Free Text Any text may be supplied.
Numeric Any numeric value may be supplied.
Regular Expression Any text that validates against a supplied .NET-style regular expression.

Selecting the type of variable will display a page used for configuring the variable's scope, default values, and any other configuration required for that type of variable. For Dropdown List variables, the following settings may be used to create a simple Yes/No variable at the Application Build level:

Create Dropdown List Variable

See Predicates for information on how to use variables to control Action Group execution.

Note that variables are a part of BuildMaster's extensibility engine.

Using a Variable Value

Variables may be used in any BuildMaster Action that accepts text input. For example, a Create File Action may be used to write the current Release Number to a text file as part of a deployment plan:

Create Version File

Any variable may be used in this manner, whether it is a system-defined variable like RELNO or any user-defined application variable. Simply use the %VARIABLENAME% notation to have BuildMaster make the replacement.

Escaping % Characters in Configuration Files and Actions

Since BuildMaster recognizes the percent sign as the start of the variable name in a line, it is necessary to escape its literal use in actions and configuration files with another % in front of it: %% . This will be replaced with a single % sign by the variables engine.

For example, if you have a configuration file that contains a URL of:

http://example.com/action?url=http%3A%2F%2Fexample.com%2Fother
You'll need to escape the % signs to prevent issues with the variable system:
http://example.com/action?url=http%%3A%%2F%%2Fexample.com%%2Fother

Built-In Variables

For your convenience, BuildMaster has a number of built-in variables which may be used in any deployment plan:

VariableReplace With
RELNOThe release number of the current build.
BLDNOThe current build number.
REFAPPIDIf there is a referenced deployable for this application, the numeric ID of that deployable's host application.
REFAPPNAMEIf there is a referenced deployable for this application, the name of that deployable's host application.
REFRELNOIf there is a referenced deployable for this application, its release number.
REFBLDNO If there is a referenced deployable for this application, its build number. If you have set "UseFurthestBuild" to "True" in the advanced configuration, this will use the build number from the furthest environment (as opposed to the largest build number).
PREVRELNOThe release number of the most recently deployed release.
PREVBLDNOThe build number of the most recently deployed release.
LASTBLDNOThe most recent build number for the current release that was created before the current build number.
DATE1A timestamp in the format of YYYYMMDD.
DATE2A timestamp in the format of YYYYMMDDHHMMSS.
DATE:d A timestamp in a custom format, where d is a valid .NET date/time format string.
APPIDThe numeric ID of the current application in BuildMaster.
APPNAMEThe name of the current application.
APPDESCThe description of the current application.
RELNAMEThe name of the release of the current build.
ENVIDThe environment ID of the currently executing build.
ENVNAMEThe environment name of the currently executing build.
DEPIDThe ID of the deployable associated with the currently executing action group.
DEPNAMEThe name of the deployable associated with the currently executing action group.
EXECUSERThe name of the user that initiated the execution.
SRCDIRThe path to the current source directory for a remote action.
TRGTDIRThe path to the current target directory for a remote action.
APPDIRThe path to the "Application Home Directory" (represented in paths by a ~\).
LASTEXITCODEThe exit code of the last process launched by an action.
LASTEXITCODEHEXThe exit code (in hexadecimal) of the last process launched by an action.
YOUR_VARIABLE_NAMEThe value of the variable with the name YOUR_VARIABLE_NAME.

This content has the following tags:

buildmasterdeployment-plansvariables