Skip to content

Variables

Joseph Larionov edited this page Oct 22, 2019 · 4 revisions

Overview

You can define and use variables in your whiskey.yml file. Use variables with this syntax: $(VARIABLE_NAME). The variable name must be enclosed in $(). If you want to include a literal $( in your whiskey.yml file, escape the dollar-sign by adding using two dollar signs, e.g. $$(.

You can add string variables to your build using Whiskey's Variable task. You can also add variables in your build script using the Add-WhiskeyVariable function. The value retains its type until the task that uses the variable begins, at which point it is converted to a string.

All static properties on .NET's Environment class are available as variables, using the property's name. They retain their underlying type, so you can call their methods/properties (see below).

All environment variables may be used as variables by using their name. For example. $(PATH) would resolve to the current user's PATH environment variable. All environment variable's are Strings. Since environment variable vary between operating systems, we recommend you use one of the static properties on .NET's Environment to get system information.

Invoking Variable Members

You are allowed to call object members on variables. Use the dot syntax, e.g. $(WHISKEY_SCM_URI.Host), $(WHISKEY_SCM_COMMIT_ID.Substring(0,7)). When calling methods, separate parameters with commas. If you want to use a comma as or in the value of a parameter, quote it with double or single quotes. Whitespace is ignored unless it is quoted by either single or double quotes, e.g.

$(Variable.Replace(  " some string ",    " another string "  ))

To use a double or single quote inside a double or single quoted string, double the quote character, e.g.

$(Variable.Replace(" ""quote"" ", " ""another quote"" "))

Built-in Variables

Whiskey has the following built-in variables.

Name Type Description
WHISKEY_BUILD_ID String The unique ID for the current build across all builds.
WHISKEY_BUILD_NUMBER Int32 The unique number/ID for the current build. Unique to the current build only. Build servers usually increment this number every time a new build runs.
WHISKEY_BUILD_ROOT DirectoryInfo The directory where your whiskey.yml file is.
WHISKEY_BUILD_SERVER_NAME String The computer name of the current build server.
WHISKEY_BUILD_STARTED_AT DateTime The date/time the build started.
WHISKEY_BUILD_URI Uri The URI to the current build. This is where you can find build results.
WHISKEY_ENVIRONMENT String The environment of the current build. This is the same environment passed to Whiskey's New-WhiskeyContext.
WHISKEY_JOB_URI Uri The URI to the project/job. This is the URI where you can see all the builds for a given project/job.
WHISKEY_MSBUILD_CONFIGURATION String The configuration used when running any MSBuild task. This is always Debug when run by developers and Release otherwise.
WHISKEY_OUTPUT_DIRECTORY String The path to the directory where build results, packages, and other output is put. Usually it is in a .output directory in the build root.
WHISKEY_PIPELINE_NAME String The name of the Whiskey pipeline that is currently running.
WHISKEY_SCM_BRANCH String The branch on which the current build is running.
WHISKEY_SCM_COMMIT_ID String The commit ID/hash that is currently building.
WHISKEY_SCM_URI Uri The URI to the source control management repository where the source code for the current build came from.
WHISKEY_SEMVER1 SemanticVersion The semver version 1 version for the current build.
WHISKEY_SEMVER1_VERSION String The MAJOR.MINOR.PATCH portion of the semver version 1 version for the current build.
WHISKEY_SEMVER2 SemanticVersion The semver version 2 version for the current build.
WHISKEY_SEMVER2_NO_BUILD_METADATA SemanticVersion The semver version 2 version for the current build, without any build metadata.
WHISKEY_SEMVER2_PRERELEASE_ID String The prerelease identifier from the prerelease label on a semver version 2 version for the current build.
WHISKEY_SEMVER2_VERSION String The MAJOR.MINOR.PATCH portion of the semver version 2version for the current build.
WHISKEY_TASK_NAME String The name of the currently executing task.
WHISKEY_TASK_TEMP_DIRECTORY DirectoryInfo The path to the temporary directory created for the currently executing task. A task's temporary directory is deleted after the task runs.
WHISKEY_TEMP_DIRECTORY DirectoryInfo The path to the global/system temporary directory. Uses System.IO.Path.GetTempPath() to get the temporary directory path.
WHISKEY_VERSION String A System.Version compatible version for the current build (i.e. a semantic version without any prerelease or build metadata).

SemanticVersion

Here are the properties available on Whiskey's SemanticVersion type.

Property Type Description
Major Int32 The major portion (i.e. first number) of the version number.
Minor Int32 The minor portion (i.e. second number) of the version number.
Patch Int32 The patch portion (i.e. third numbrer) of the version number.
Prerelease String Prerelease metadata, if any.
Build String Build metadata, if any.
Clone this wiki locally