Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Set Variable action can be used to replace, increment or append to the value of Build variables, Server variables and Agent variables. Build variables are specific to the current build and are accessible during the build using the expression %MyVariable%. They inherit the value of the Configuration, Project or Application server variable at the start of the build.  Only the initial value of the server variable is accessible by the build. This is referred to as the agent variable can be referenced using expressions prefixed with a namespace, such as %Configuration.VariableName%, %Project.VariableName% and %Application.VariableName%.

Set Variable

Image Added

Set Variable (work in progress)

Image Removed

Name

A friendly name for this action (will be displayed in the actions workflow area).

...

Note: Any date time variable values should be entered as UTC. Full date time format is: yyyy-MM-dd'T'HH:mm:ss'Z' e.g. 2099-12-31T23:59:59Z

Expand

...

expressions in new value

If  this option is ticked, then the New Value will be expanded (if there's any expressions in it) before it is used to replace, append, or increment the variable's value.

...

Regular Expressions

Available for the "Replace using a regular expression" operation. 

Image Added

Pattern

A regular expression pattern to match against the existing value of the variable. 

...

When ticked only the first regular expression pattern match will be replaced

Replace With

Available for the "Replace using a regular expression" operation. This text will used to replace regular expression matches in the variable's value. This may contain back references to captured groups in the regular expression pattern, see Substitutions in Regular Expressions. Note, if the Expand expressions in replacement value option is ticked, these will need to be escaped e.g. $1 => $$1 if expanding.

Expand expressions in replacement value

If  this option is ticked, then the Replace With will be expanded (if there's any expressions in it) before it is used to replace regular expression matches in the variable's value.

Options

Image Added

Set

This drop down contains a list of variable types that this action can set:

  • Build variable: This is the default option and is used to set the value of the build variable only.

    Build variables inherit the value of the Configuration, Project or Application server variable at the start of the build. Changes to the build variable, either manually entered into the Queue Options prompt or set by actions such as this one are specific to the build. Build variables are not accessible by other builds.

    Note that, after running this action, you can reference the build variable's original value by using %Configuration.MyVariable%. Otherwise, to use the updated value, simply reference the variable by its name %MyVariable%.
  • Server variable:  This option is used to set the value of Configuration, Project and Application variables.

    These are the variables that you can edit manually on the server and are referred to as Server variables. The values of these variables determine the initial value of build variables at the start of each build. Server variables are therefore accessible across multiple builds within their defined scope.
    The variable with the most specific namespace is set. e.g. if the configuration variable is defined, then the configuration variable value is set, otherwise if the project variable is defined, then the project variable value is set, otherwise the application variable value is set. 

    Note that the updated server variable value cannot be referenced during the build - unless loaded into a build variable. This can be done either with the next option, or using a Load Variable action or Load Build Variable build event handler.

  • Server variable and overwrite build variable with result:  This option allows you to set both the server variable and the build variable.

...