Environment Variables
Note that you should place environment variables (if you override the default, for example), in:
./bin/env/VARIABLE_NAME.sh
Where VARIABLE_NAME is the name of your environment variable. environmentAddFile does this for you if you want.
These are the known environment variables in Zesk Build - to see the default behavior look at in ./bin/build/env.
You can document your environment variables automatically using Type: and a description using comments and the
standard Zesk Build bash comment syntax of # Name: value
So an example environment file is:
#!/usr/bin/env bash
# Type: String
# Category: Documentation
# ID of CloudFront provider for web site, for invalidation
export DOCUMENTATION_CLOUDFRONT_ID
DOCUMENTATION_CLOUDFRONT_ID="${DOCUMENTATION_CLOUDFRONT_ID-}"
The values for Type: match standard types. The Category: simply places it that documentation
category. The behavior here is to set the environment variable to blank unless it is set already. Most project
environment variables will follow this pattern unless they are derived from other environment variables and the idea is
that this value should come from, you know, the environment.
The exception to this is derived values (based on another environment variable, for example but can be specified) or values which can be computed easily.
It's important to avoid logic in the environment loader file unless you are strict about access to the environment
variable solely through the buildEnvironmentLoad and
buildEnvironmentGet calls as it is NOT a requirement to
accessing environment variables, rather a convenience.
As well, note that variables documented in this manner can generate their own documentation, and the type can be used to validate environment variables.
Note that most environment variables will simply inherit the already-set value (as shown in the example above), except
in cases where it more of a project configuration such as APPLICATION_NAME or APPLICATION_JSON, for example.
Project configuration variables:
APPLICATION_NAME,APPLICATION_JSON,APPLICATION_JSON_PREFIX,BUILD_HOOK_EXTENSIONS,APPLICATION_CODE_EXTENSIONS,APPLICATION_CODE
See also
Categories of Environment Variables
Amazon Web Services
AWS_ACCESS_KEY_DATEDate. Date of key expiration which can be checked in pipelines. Not part of the Amazon specification but a good idea to track expiration of keys.AWS_ACCESS_KEY_IDString. Amazon Web Services IAM IdentityAWS_PROFILEString. Default profile for Amazon Web ServicesAWS_REGIONString. Region for Amazon Web ServicesAWS_SECRET_ACCESS_KEYSecret. Private Secret Password for AWS
Application
APPLICATION_CODEString. This is the unique code name of the application. Use a domain name suffix to ensure global uniqueness.APPLICATION_CODE_EXTENSIONSColonDelimitedList. List of extensions for code in the application. Required.APPLICATION_CODE_IGNOREColonDelimitedList. List of extensions for code in the application. Required.APPLICATION_JSONApplicationFile. Path to the application configuration JSONAPPLICATION_JSON_PREFIXString. Prefix to place we can store things in the JSON file (e.g. to set the fingerprint)APPLICATION_NAMEString. This is the display name of the applicationBUILD_COMPANYString. Legal copyright holder for this codebaseBUILD_COMPANY_LINKURL. Legal copyright holder website for this codebaseBUILD_HOOK_EXTENSIONSColonDelimitedList. List of extensions to run when looking for hooksBUILD_MAINTENANCE_CREATED_FILEBoolean. When true, means the.env.localfile was created by the maintenance hook and should be deleted when maintenance is no longer enabled.BUILD_MAINTENANCE_MESSAGE_VARIABLEEnvironmentVariable. Name of the environment variable (if any) which reflects the current maintenance message. notesBUILD_MAINTENANCE_VARIABLEEnvironmentVariable. The variable notesBUILD_PROJECT_DEACTIVATEFunction. Set this to a function which cleans up the project context and will be run onproject-deactivatehook which is sourced.
Bash
DISPLAYString.EDITORCallable. Binary for editing filesHOMEDirectory. Centralizing access to environment variables in code has the added benefit we can add debugging here if neededLC_TERMINALString. LC_TERMINAL typically identifies the terminal applicationMANPATHDirectoryList. A colon:separated list of paths to search for manual pages. SeemanPathConfigurePATHDirectoryList. A colon:separated list of paths to search for executables inbash. SeepathConfigurePRODUCTIONBoolean. Is this a production system? e.g. remove unnecessary runtime checks.PROMPT_COMMANDCallable. Command is run prior to displaying the prompt, receives exit status from prior commandPS1String. Bash Prompt for terminalsTERMString.VISUALExecutable. Binary for viewing files
Bash Prompt
__BASH_PROMPT_MARKERSArray. List of markers to identify to the terminal location of the prompt__BASH_PROMPT_MODULESArray. List of modules to run each prompt command__BASH_PROMPT_PREVIOUSArray. Previous result code
Build Configuration
BUILD_CACHE_HOMEDirectory. Location for the build system cache files. Defaults to$HOME/.buildand if$HOMEis not a directory then$(buildHome)/.buildCache MAY be deleted at any time. If you need your files to be preserved, store them elsewhere.BUILD_DEBUGCommaDelimitedList. 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.BUILD_DEBUG_LINESPositiveInteger. Number of lines of debugging output to send to stderr before stoppingBUILD_ENVIRONMENT_DIRSDirectoryList. Search directory for environment definition files.:separated. notesBUILD_HOMEDirectory.BUILD_HOMEis.when this code is installed - at./bin/build. Usually an absolute path and does NOT end with a trailing slash. This is computed from the current source file using${BASH_SOURCE[0]}.BUILD_HOOK_DIRSApplicationDirectoryList. List of directories to search for hooks. Defaults tobin/hooks:bin/build/hooks. Colon (:) separated list.BUILD_INSTALL_URLURL.BUILD_INSTALL_URLforinstallInstallBuild- source URL for a raw installer.BUILD_INTERACTIVE_REFRESHPositiveInteger. When displaying content interactively, how many seconds should elapse before refreshing content?BUILD_MAXIMUM_TAGS_PER_VERSIONPositiveInteger. Number of versions tags (d0, d1, d2, etc.) to look for before giving up ingitTagVersionBUILD_NOTIFY_SOUNDString. Sound for notifications. Set to-for no sound. Defaults tozesk-build-notification.BUILD_PRECOMMIT_EXTENSIONSList. List of extensions for which build hooks may be written and run notesBUILD_RELEASE_NOTESApplicationDirectory. Constant for the release notes path. Defaults to./docs/release.BUILD_VERSION_NO_OPENBoolean. Constant for whether to open release notes when a version is requested (seeversion-already)BUILD_VERSION_SUFFIXString. Default suffix used ingitTagVersionIP_URLURL. URL to look up IP my address remotelyIP_URL_FILTERString. jq filter to parse IP_URL result (assuming JSON) if blank, no filter is used and raw result is returnedXDG_CACHE_HOMEDirectory. Base directory for user-specific cache data to be storedXDG_CONFIG_DIRSDirectoryList. Search directory for user-specific configuration files to be stored.:separated.XDG_CONFIG_HOMEDirectory. Location for configuration filesXDG_DATA_DIRSDirectoryList. Search directory for user-specific data files to be stored.:separated.XDG_DATA_HOMEDirectory. Base directory for user-specific data to be storedXDG_STATE_HOMEDirectory. Base directory for user-specific state files to be stored
Continuous Integration
BITBUCKET_CLONE_DIRDirectory. Defined in BITBUCKET Pipelines Typically should match BUILD_HOMEBITBUCKET_REPO_SLUGString. Defined in BITBUCKET Pipelines, represents the project code name.BITBUCKET_WORKSPACEString. Defined in BITBUCKET Pipelines. represents the project workspace.BUILD_DOCKER_BITBUCKET_IMAGEString.BUILD_DOCKER_BITBUCKET_PATHRemoteDirectory.CIString. If this value is non-blank, then consolestatusMessages are just output normally. notes
Decoration
BUILD_COLORSBoolean. If true then colors are shown, blank means guess the value, false means no colorsBUILD_COLORS_MODEString. light or darkBUILD_PAIR_WIDTHPositiveInteger. Width for pairs. Defaults to40.BUILD_PROMPT_COLORSColonDelimitedList. Colon-separated list of colors for the prompt notesBUILD_TEXT_BINARYCallable. Binary used to generatebigTextBUILD_URL_BINARYCallable. Binary used in __urlOpenCOLORFGBGString. Standard way to express the foreground and background colors notes
Deployment
APPLICATION_BUILD_DATEDate. Time when a build was initiated, set upon first invocation if not alreadyAPPLICATION_IDString. This is the unique hash which represents the source code state (typically a git hash)APPLICATION_REMOTE_HOMERemoteDirectory. Path on the remote server where the application is servedAPPLICATION_TAGString. This is the full version number including debugging or release identifiersAPPLICATION_VERSIONString. This is the version number which can be displayedBUILD_TARGETString. The file to generate when generating buildsBUILD_TIMESTAMPInteger. Time when a build was initiated, set upon first invocation if not alreadyDEPLOYMENTString. Target deployment for this codeDEPLOY_REMOTE_HOMERemoteDirectory. Path on the remote server where the application deployment home is (per application)DEPLOY_USER_HOSTSString. A list of one ore more user@host for installation of the applicationGITHUB_REPOSITORY_OWNERString. Repository owner for release
Development
BUILD_DEVELOPMENT_HOMEString. Directory where Zesk Build is being developed in the file system (for other projects to test against a changed version)GITHUB_ACCESS_TOKENString. Access token used for releaseGITHUB_ACCESS_TOKEN_EXPIREDate. GitHub Access token expiration date. Invalid AFTER this date.GITHUB_REPOSITORY_NAMEString. Repository name for releaseGIT_BRANCH_FORMATString.GIT_OPEN_LINKSBoolean. Open links from git remotes ingitCommitGIT_REMOTEString.
Docker
BUILD_DOCKER_IMAGEString. Default docker image to use when launchingdockerLocalContainerBUILD_DOCKER_PATHRemoteDirectory. Default path for the shell to map the current directory to when launchingdockerLocalContainerBUILD_DOCKER_PLATFORMString. notes
Documentation
BUILD_DOCUMENTATION_SOURCE_LINK_PATTERNString. Links in documentation
Installation
BUILD_COMPOSER_VERSIONString. Version of composer to use for building vendor directoryBUILD_NPM_VERSIONString. Version of npm to install using nativenpmbinary.BUILD_PACKAGE_MANAGERExecutable. The default package manager on systems which have more than one package manager available.
Internal
__BUILD_HAS_TTYBoolean. Cached value of the availability of/dev/ttynotes
PHP
XDEBUG_ENABLEDBoolean. Is xdebug enabled? Calling application can honor this environment variable to automatically connect to the debugger.
Testing
BUILD_TEST_FLAGSString. Test flags affect controls and how tests are run.TEST_TRACK_ASSERTIONSBoolean. Turn on or off tracking of function assertions within the testing core If blank, the default behavior is to track; disable it with setting the value tofalse
Vendor
APACHE_HOMEDirectory. Constant for the Apache configuration home directoryBUILD_YARN_VERSIONString. Version of yarn to install usingcorepackDAEMONTOOLS_HOMEDirectory. Constant for the directory where services are monitored by daemontoolsMARIADB_BINARY_CONNECTExecutable. MariaDB binary for database connectionsMARIADB_BINARY_DUMPExecutable. MariaDB binary for dumpNODE_PACKAGE_MANAGERExecutable. The package manager used for node operations. Usuallyyarnornpm. Default isyarn.
Additional Details on Environment Variables
BUILD_DOCKER_PLATFORM
Type: String • Category: Docker
The platform for dockerLocalContainer
Contacts of this can be found via docker buildx ls
Valid values are:
linux/arm64linux/amd64linux/amd64/v2linux/riscv64linux/ppc64lelinux/s390xlinux/386linux/mips64lelinux/mips64linux/arm/v7linux/arm/v6
If not specified, uses the default for the current platform.
BUILD_ENVIRONMENT_DIRS
Type: DirectoryList • Category: Build Configuration
Search directory for environment definition files. : separated.
Note these should be in addition to the default environment variables ALWAYS located at $(buildHome)/bin/build/env
THe default is $(buildHome)/bin/env. Make sure to append to this as a :-list.
BUILD_MAINTENANCE_MESSAGE_VARIABLE
Type: EnvironmentVariable • Category: Application
Name of the environment variable (if any) which reflects the current maintenance message.
Default is MAINTENANCE_MESSAGE and this is typically added to the .env.local to a live
application. Your application should monitor these files for changes if they are cached and reload as needed to ensure
these messages are displayed immediately.
BUILD_MAINTENANCE_VARIABLE
Type: EnvironmentVariable • Category: Application
The variable
The maintenance variable which enables (or disabled) maintenance mode.
This value is set to true or false
BUILD_PRECOMMIT_EXTENSIONS
Type: List • Category: Build Configuration
List of extensions for which build hooks may be written and run
Presence in this list simply means it may run, not that it is written or runs; add your own
bin/hooks/pre-commit-XXX.sh to handle a specific file type in your application.
Currently:
- sh - Bash
- PHP - PHP
- js - JavaScript
- json - JSON
- md - Markdown
- yml - Yet Another Markup Language
- txt - Text files
- py - Python
- go - Golang
- rs - Rust
- css - CSS
- less, sass, scss - Compiled stylesheets
BUILD_PROMPT_COLORS
Type: ColonDelimitedList • Category: Decoration
Colon-separated list of colors for the prompt
Colors are escape codes. Last entry is a reset simply to make environment output less messy.
- Success color
- Failure color
- User
- Host
- Path
CI
Type: String • Category: Continuous Integration
If this value is non-blank, then console statusMessages are just output normally.
Continuous Integration - this is set to a non-blank value in:
- Bitbucket pipelines
COLORFGBG
Type: String • Category: Decoration
Standard way to express the foreground and background colors
- Format is:
foregroundColor;backgroundColor foregroundColor- UnsignedInteger. 0 to 16backgroundColor- UnsignedInteger. 0 to 16
Not referenced in this product; referenced via rxvt and may be honored at some point.
__BUILD_HAS_TTY
Type: Boolean • Category: Internal
Cached value of the availability of /dev/tty
Possible values are true or false or blank.
- true - /dev/tty appears to be operating without errors
- false - /dev/tty appears to be disconnected and can not be used
This value is set automatically by isTTYAvailable and caches the value using this environment variable to avoid testing again.