Built-in Functions & Variables
- 14 May 2021
- 4 Minutes to read
- Print
- DarkLight
- PDF
Built-in Functions & Variables
- Updated on 14 May 2021
- 4 Minutes to read
- Print
- DarkLight
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
This is generated from the built in components of Otter 3.0.0, and may be different than what you have installed (especially if you have extensions); go to [User Icon] -> Documentation within your BuildMaster instance to see exactly what operations are available.
Executions
- $EnvironmentName - Gets the name of the current environment in context, or attempts to determine a single environment in context based on server, role, and job.
- $ExecutionId - Returns the current execution ID.
- $ExecutionState - Returns the current state of the execution (normal, warning, or error).
- GetVariableValue(VariableName, [VariableType]) - Returns the value of a variable if the specified variable name is available in the current context; otherwise returns null.
- $IsSimulation - Returns "true" if the execution is a simulation; otherwise, returns "false".
- $IsVariableDefined(VariableName, [VariableType]) - Returns true if the specified variable name is available in the current context; otherwise returns false.
- $WorkingDirectory - Returns the current working directory.
Files
- $DirectoryExists(name) - Returns "true" if the specified directory exists on the current server.
- $FileContents(FileName, [MaxLength]) - Returns the contents of a text file.
- $FileContents(name, [maxLength]) - Returns the contents of a file on the current server.
- $FileExists(name) - Returns "true" if the specified file exists on the current server.
- @FilesOnDisk(includes, [excludes], [directory]) - Returns a list of files matching the mask on the current server.
- $PathCombine(Path1, Path2) - Returns a string containing all of the arguments combined into a complete path.
- $ResolvePath(Path) - Provides an absolute path (terminated with directory separator) based on a relative path and the current working directory; this will provide appropriate directory separators, based on the server in context
General
- $Date([Format]) - Returns the current date and time of the local timezone in the specified .NET datetime format string, or ISO 8601 format (yyyy-MM-ddTHH:mm:ss) if no format is specified.
- $DateUtc([Format]) - Returns the current UTC date and time in the specified .NET datetime format string, or ISO 8601 format (yyyy-MM-ddTHH:mm:ss) if no format is specified.
- Eval(Text) - Performs variable substitution and function evaluation for arbitrary text.
- @Range(Start, Count) - Returns a range of integers starting from a specified value.
- $SecureCredentialProperty(credential, property) - the decrypted plain text value of a specified credentials property
- $SecureResourceProperty(resource, property) - the value of a specified secure resource property
- $SpecialWindowsPath(Name) - Returns the full path of a special directory on a Windows system.
JSON
- FromJson(json) - Converts JSON to an OtterScript value.
- $JSEncode(Text) - Encodes a string for use in a JavaScript string literal.
- $ToJson(data) - Converts an OtterScript value to JSON.
Linux
- $SHEval(ScriptText) - Returns the output of a shell script.
Lists
- @ListConcat - Creates a list containing the contents of each list in sequence.
- $ListCount(List) - Count the number of elements in a list.
- $ListIndexOf(List, Item) - Finds the index of an item in a list. Finding the first item in a list returns 0, and finding an item not present in the list returns -1.
- @ListInsert(List, Item, [Index]) - Inserts an item into a list.
- ListItem(List, Index) - Gets an item from a list.
- @ListRemove(List, Index) - Removes an item from a list.
Maps
- MapAdd(Map, Key, Value) - Adds a key-value pair to a map.
- MapItem(Map, Key) - Gets an item from a map.
- @MapKeys(Map) - Lists the keys of a map.
- MapRemove(Map, Key) - Removes a key from a map.
Math
- $Compare(Arg1, Operator, Arg2, [AsNumber]) - Compare two values numerically or as case-sensitive strings.
- $Decrement(value, [amount]) - Returns a string that contains the result of decrementing a value.
- $Increment(value, [amount]) - Returns a string that contains the result of incrementing a value.
PowerShell
- $PSCredential(UserName, [Password]) - Returns a PSCredential object that can be passed to PowerShell scripts.
- PSEval(ScriptText) - Returns the result of a PowerShell script.
Servers
- @AcquiredServers(Role) - list of all of the servers acquired for a specified role
- @AllEnvironments - Returns a list of all environments.
- @AllRoles - Returns a list of all server roles.
- @AllServers([IncludeInactive]) - Returns a list of all servers.
- $EnvironmentVariable(EnvironmentVariableName) - Returns the value of the specified environment variable on the current server.
- $RoleName - name of the current server role in context
- $ServerName - Gets the name of the current server in context.
- $ServerName - name of the current server in context
- @ServersInEnvironment([EnvironmentName], [IncludeInactive]) - Returns a list of all the servers in the specified environment name.
- @ServersInRole([RoleName], [IncludeInactive]) - Returns a list of servers in the specified role.
- @ServersInRoleAndEnvironment([RoleName], [EnvironmentName], [IncludeInactive]) - Returns a list of all the servers in the specified role and environment name.
Strings
- $Coalesce - Returns the first argument which does not contain only whitespace.
- $HtmlEncode(Text) - Encodes a string for use in HTML.
- $Join(Separator, Values) - Concatenates all elements of a list into a string using a specified separator.
- $JSEncode(Text) - Encodes a string for use as a JavaScript literal.
- $MatchesRegex(Text, RegexPattern) - Returns true when the specified text matches the specified pattern; otherwise returns false.
- $NewLine([WindowsOrLinux]) - newline string for either the operating system of the current server in context or specifically Windows or Linux
- $PadLeft(Text, Length, [PadCharacter]) - Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified character, for a specified total length.
- $PadRight(Text, Length, [PadCharacter]) - Returns a new string that left-aligns the characters in this instance by padding them on the left with a specified character, for a specified total length.
- @RegexFind(Text, MatchExpression, [MatchGroup]) - Finds all matches of a regular expression in a string, optionally returning only a matched group.
- $RegexReplace(Text, MatchExpression, ReplaceWith) - Searches for and replaces text in a string using a regular expression.
- $Replace(Text, Value, ReplaceWith, [IgnoreCase]) - Searches for and replaces text in a string.
- @Split(Text, Separator, [Count]) - Splits a string into substrings based on a specified separator.
- $Substring(Text, Offset, [Length]) - Returns a segment of another string.
- $ToLower(Text) - Returns a string with all letters converted to lowercase.
- $ToUpper(Text) - Returns a string with all letters converted to uppercase.
- $Trim(Text) - Returns a string with all leading and trailing whitespace characters removed, or optionally a set of specified characters.
- $TrimEnd(Text) - Returns a string with all trailing whitespace characters removed, or optionally a set of specified characters.
- $TrimStart(Text) - Returns a string with all leading whitespace characters removed, or optionally a set of specified characters.
- $UrlEncode(Text) - Escapes a string for use in a URL.
XML
- $XmlEncode(Text) - Encodes a string for use in an XML element.
Was this article helpful?