EnvironmentAliases.

EnvironmentVariable<T>(ICakeContext, string, T) Method

Summary

Retrieves the value of the environment variable or defaultValue if the environment variable does not exist.
Namespace
Cake.Common
Containing Type
EnvironmentAliases

Syntax

[CakeMethodAlias]
[CakeAliasCategory("Environment Variables")]
public static T EnvironmentVariable<T>(this ICakeContext context, string variable, T defaultValue)

Examples

Information(EnvironmentVariable<int>("BUILD_NUMBER", 42));

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.
CakeAliasCategoryAttribute An attribute used for documentation of alias methods/properties.

Type Parameters

Name Description
T The environment variable type.

Parameters

Name Type Description
context ICakeContext The context.
variable string The environment variable.
defaultValue T The value to return if the environment variable does not exist.

Return Value

Type Description
T The environment variable or defaultValue if the environment variable does not exist.