Skip to content

Common Task Properties

Joseph Larionov edited this page Aug 7, 2020 · 4 revisions

Every Whiskey task has these properties.

Debug

Overview

Shows a task's debug messages in your build output. Must be set to true, 1, or yes.

Example

Build:
- Log:
    Debug: true
    Level: Debug
    Message: Some debug-level information.

ErrorAction

Overview

Controls how a task's errors are handled. To fail a build if an error is written, set this to Stop. To hide any errors the task is writing, set this to Ignore. This property has no effect on any errors a task may write that fails/terminates a build, i.e. this property only applies to non-terminating errors.

Example

- Log:
    ErrorAction: Stop
    Level: Error
    Message: Stop the build!

ExceptBy

Overview

Controls if a task runs if the build was not started by a developer or a build server. By default, a task always runs. Valid values are Developer or BuildServer. If set to Developer, does not run when the build is running by a developer. If set to BuildServer, does not run when run by a build server.

Example

- Log:
    ExceptBy: Developer
    Message: Only build servers will see this message.

ExceptDuring

Overview

Controls what run modes a task will not run under. Valid values and modes are Initialize, Build, and Clean. Can be set to multiple modes. If set, the task will run in all modes but the ones in the list. Make sure the task actually runs in the chosen mode. Some tasks don't have anything to clean or initialize, in which case these properties would have no affect.

Example

Build:
- Log:
    ExceptDuring: Build
    Message: I'm either cleaning or initializing.

ExceptOnBranch

Overview

Controls what branch a task should not run on. By default, a task runs on every branch. When a build is run by a developer, there is no branch information, so tasks that have this property will never run. Wildcards are supported.

Example

Build:
- Log:
    ExceptOnBranch: "feature/*"
    Message: I'm not running on a feature branch.

ExceptOnPlatform

Overview

Controls the platforms on which the task will not run. By default, a task runs on all platforms. Supported platforms and values are Windows, Linux, and MacOS. Can be a list of multiple platforms.

Examples

Build:
- Log:
    ExceptOnPlatform:
    - MacOS
    - Linux
    Message: I'm running on Windows!

IfExists

Overview

Only runs a task if an item exists. You can use any PowerShell-supported path:

  • env:ENV_NAME for environment variables
  • hklm:\path\to\key for registry keys
  • path\to\file for files/directories

Relative paths are file system paths and are resolved from the directory of the build root or the task's working directory

Example

Build:
- Log:
  IfExists: "env:ENABLE_LOGGING"
  Message: Only show this message if the ENABLE_LOGGING environment variable exists.

InformationAction

Overview

Controls the visibility of a task's information messages. Valid values are:

  • Stop: fail the build if the task writes an information message
  • Continue: show a task's information messages (the default)
  • Ignore: don't write any information messages
  • SilentlyContinue: write but don't show any information messages

Examples

Build:
- Log:
    InformationAction: Ignore
    Message: I'm not visible. Seems like a strange thing to do.

OnlyBy

Overview

Controls if a task runs if the build was started by a developer or a build server. By default, a task always runs. Valid values are Developer or BuildServer. If set to Developer, only runs when the build is running by a developer. If set to BuildServer, only runs when the build is running by a build server.

Example

- Log:
    OnlyBy: Developer
    Message: Only developers will see this message.

OnlyDuring

Overview

Controls what run modes a task will run under. Valid values and modes are Initialize, Build, and Clean. Can be set to multiple modes. If set, the task will run in all the modes in the list. Make sure the task actually runs in the chosen mode. Some tasks don't have anything to clean or initialize, in which case these properties would have no affect.

Example

- Log:
    OnlyDuring: Build
    Message: You'll only see this when building.

OnlyOnBranch

Overview

Controls what branch a task should run on. By default, a task runs on every branch. Use this to only run a task on specific branches. When a build is run by a developer, there is no branch information, so tasks that have this property will never run. Wildcards are supported.

Example

Build:
- Log:
    OnlyOnBranch: "feature/*"
    Message: I'm only running on feature branches.

OnlyOnPlatform

Overview

Controls the platforms on which the task will run. By default, a task runs on all platforms. Supported platforms and values are Windows, Linux, and MacOS. Can be a list of multiple platforms.

Examples

Build:
- Log:
    OnlyOnPlatform:
    - MacOS
    - Linux
    Message: I'm never running on Windows!

OutVariable

Overview

Redirects a task's output to a Whiskey variable. The task output will not be visible in the build log.

Examples

Build:
- Exec:
    OutVariable: TASK_OUTPUT
    Path: cmd.exe
    Argument:
    - /C
    - ECHO I will be redirected to the TASK_OUTPUT Whiskey variable.

UnlessExists

Overview

Only runs a task if an item does not exist. You can use any PowerShell-supported path:

  • env:ENV_NAME for environment variables
  • hklm:\path\to\key for registry keys
  • path\to\file for files/directories

Relative paths are file system paths and are resolved from the directory of the build root or the task's working directory

Example

Build:
- Log:
  UnlessExists: "env:DISABLE_LOGGING"
  Message: Don't show this message if the DISABLE_LOGGING environment variable exists.

Verbose

Overview

Shows a task's verbose messages. Set this to true to show verbose messages or false to not show verbose messages. Setting the value to false only makes sense if the global VerbosePreference is Continue but you want to omit a specific task's verbose messages from your output.

Example

Build:
- Log:
    Verbose: true
    Level: Verbose
    Message: Makes sure this message gets shown.

WarningAction

Overview

Shows or hides a task's warning messages. Valid values are:

  • Stop: stop and fail a build if a task outputs a warning message.
  • Ignore: don't write any warning messages
  • SilentlyContinue: write but don't show warning messages
  • Continue: show a task's warning messages

Example

Build:
- Log:
    Level: Warning
    WarningAction: Ignore
    Message: This message will never get written. Sad.

WorkingDirectory

Overview

The directory in which the task should run. By default, this is the directory of the whiskey.yml file being used to run the build. Should be a path relative to the whiskey.yml file used. The directory must exist.

Example

Build:
- Log:
    WorkingDirectory: some_dir
    Message: $(WorkingDirectory.FullName)
Clone this wiki locally