Hooks
Hooks are called to enable custom actions at specific times which can be overwritten or intercepted by the application.
Usage
hookExists [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] [ hookName0 ]
Does a hook exist in the local project? Check if one or more hook exists. All hooks must exist to succeed.
Arguments
--application applicationHome- Path. Optional. Directory of alternate application home. Can be specified more than once to change state.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.--next scriptName- File. Optional. Locate the script found after the named script, if any. Allows easy chaining of scripts.hookName0- one or more hook names which must exist
Return codes
0- If all hooks exist
Environment
- BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list. BUILD_DEBUG - CommaDelimitedList. Constant for turning debugging on during build to find errors in the build scripts. Enable debugging globally in the build scripts. Set to a comma (,) delimited list string to enable specific debugging, ortruefor ALL debugging,false(or blank) for NO debugging.
Usage
hookRun [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] hookName [ ... ] [ --help ]
Run a hook in the project located at ./bin/hooks/
See (Hooks documentation)[../hooks/index.md] for standard hooks.
Hooks provide an easy way to customize your build. Hooks are binary files located in your project directory at ./bin/hooks/ and are named hookName with a .sh extension added.
So the hook for version-current would be a file at:
bin/hooks/version-current.sh
Sample hooks (scripts) can be found in the build source code at ./bin/hooks/.
Default hooks (scripts) can be found in the current build version at bin/build/hooks/
Arguments
--application applicationHome- Path. Optional. Directory of alternate application home.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.--next scriptName- File. Optional. Run the script found after the named script, if any. Allows easy chaining of scripts.hookName- String. Required. Hook name to run....- Arguments. Optional. Any arguments to the hook. See each hook implementation for details.--help- Flag. Optional. Display this help.
Debugging settings
Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:
hook-hookRunandhookSourceand optional versions of the same functions will output additional debugging information
Examples
version="$(hookRun version-current)"
Return codes
Any- The hook exit code is returned if it is run1- is returned if the hook is not found
Environment
- BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list. BUILD_DEBUG - CommaDelimitedList. Constant for turning debugging on during build to find errors in the build scripts. Enable debugging globally in the build scripts. Set to a comma (,) delimited list string to enable specific debugging, ortruefor ALL debugging,false(or blank) for NO debugging.
Usage
hookSource [ --application applicationHome ] [ --extensions extensionList ] hookName ...
Run a hook in the project located at ./bin/hooks/
See (Hooks documentation)[../hooks/index.md] for standard hooks.
Hooks provide an easy way to customize your build. Hooks are binary files located in your project directory at ./bin/hooks/ and are named hookName with a .sh extension added.
So the hook for version-current would be a file at:
bin/hooks/version-current.sh
Sample hooks (scripts) can be found in the build source code at ./bin/hooks/.
Default hooks (scripts) can be found in the current build version at bin/build/hooks/
Arguments
--application applicationHome- Path. Optional. Directory of alternate application home.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.hookName ...- String. Required. Hook to source.
Debugging settings
Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:
hook-hookRunandhookSourceand optional versions of the same functions will output additional debugging information
Examples
version="$(hookSource version-current)"
Return codes
Any- The hook exit code is returned if it is run1- is returned if the hook is not found
Environment
- BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list. BUILD_DEBUG - CommaDelimitedList. Constant for turning debugging on during build to find errors in the build scripts. Enable debugging globally in the build scripts. Set to a comma (,) delimited list string to enable specific debugging, ortruefor ALL debugging,false(or blank) for NO debugging.
Usage
hookRunOptional [ --next scriptName ] [ --application applicationHome ] [ --extensions extensionList ] hookName [ ... ] [ --help ]
Identical to hookRun but returns exit code zero if the hook does not exist.
Arguments
--next scriptName- File. Optional. Run the script found after the named script, if any. Allows easy chaining of scripts.--application applicationHome- Path. Optional. Directory of alternate application home.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.hookName- String. Required. Hook name to run....- Arguments. Optional. Any arguments to the hook. See each hook implementation for details.--help- Flag. Optional. Display this help.
Debugging settings
Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:
hook-hookRunandhookSourceand optional versions of the same functions will output additional debugging information
Examples
version="$(hookRunOptional version-current)"
Return codes
Any- The hook exit code is returned if it is run1- is returned if the hook is not found
Environment
-
BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
-
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list.
Usage
hookSourceOptional [ --application applicationHome ] [ --extensions extensionList ] hookName ...
Identical to hookRun but returns exit code zero if the hook does not exist.
Arguments
--application applicationHome- Path. Optional. Directory of alternate application home.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.hookName ...- String. Required. Hook to source (if it exists).
Debugging settings
Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:
hook-hookRunandhookSourceand optional versions of the same functions will output additional debugging information
Examples
hookSourceOptional test-cleanup
Return codes
Any- The hook exit code is returned if it is run0- is returned if the hook is not found
Environment
-
BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
-
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list. -
BUILD_DEBUG - CommaDelimitedList. Constant for turning debugging on during build to find errors in the build scripts. Enable debugging globally in the build scripts. Set to a comma (
,) delimited list string to enable specific debugging, ortruefor ALL debugging,false(or blank) for NO debugging.
Usage
hookFind [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] hookName0 [ hookName1 ]
Does a hook exist in the local project?
Find the path to a hook. The search path is:
- ./bin/hooks/
- ./bin/build/hooks/
If a file named hookName with the extension .sh is found which is executable, it is output.
Arguments
--application applicationHome- Path. Optional. Directory of alternate application home. Can be specified more than once to change state.--extensions extensionList- ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults toBUILD_HOOK_EXTENSIONS.--next scriptName- File. Optional. Locate the script found after the named script, if any. Allows easy chaining of scripts.hookName0- String. Required. Hook to locatehookName1- String. Optional. Additional hooks to locate.
Return codes
0- Success1- Environment error2- Argument error
Environment
- BUILD_HOOK_EXTENSIONS - ColonDelimitedList. List of extensions to run when looking for hooks
BUILD_HOOK_DIRS - ApplicationDirectoryList. List of directories to search for hooks. Defaults to
bin/hooks:bin/build/hooks. Colon (:) separated list. BUILD_DEBUG - CommaDelimitedList. Constant for turning debugging on during build to find errors in the build scripts. Enable debugging globally in the build scripts. Set to a comma (,) delimited list string to enable specific debugging, ortruefor ALL debugging,false(or blank) for NO debugging.
See Defined Hooks