EnvironmentExtensions.

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

Summary

Retrieves the value of the environment variable or returns the default value specified if missing
Assembly
Cake.Incubator.dll
Namespace
Cake.Incubator
Containing Type
EnvironmentExtensions

Syntax

public static T EnvironmentVariable<T>(this ICakeContext context, string variable, T defaultValue)

Examples

Returns the build number integer, defaulting to 1 if unspecified
var buildNumber = EnvironmentVariable<int>("BUILD_NUMBER", 1);

Attributes

Type Description
CakeMethodAliasAttribute
CakeAliasCategoryAttribute

Type Parameters

Name Description
T The type of the environment variable

Parameters

Name Type Description
context ICakeContext The context.
variable string The environment variable name.
defaultValue T The value to return if the environment variable is missing.

Return Value

Type Description
T The value of the argument if it exist; otherwise defaultValue.