Environment variables
Environment variables are pairs of key-and-value that can be used in the pipelines instead of manually updating the same values. They allow developers to save time looking up and entering access details, and eliminate the risk of providing sensitive details in their scripts.
ENV VARs are used to parameterize build scripts. Setting up variables in a pipeline will cause the same build action to work differently depending on the pipeline.
Setting environment variables
When adding a new variable, the following fields are available:
- Scope – defines the level of the variable
- Encryption – enabling encryption will hide the value of the variable in the logs
- Type – if you set it to Fixed, the value of the variable will always be the same. Switching the option to Settable will let you change the value and pass it to the next action or execution
Environment Variables can be defined on 4 levels:
- Workspace
- available for all projects and pipelines. Configured in the workspace Preferences.
- Project
- available for all pipelines in the project. Configured in the Project Options.
- Pipeline
- available only for the pipeline where was created (eg. production server details). Configured in the pipeline details.
- Action
- available only for the actions where the variable was defined
Workspace environment variables
Example Usage
Let's configure some variables to encrypt access to an FTP server:
- Go to your deployment pipeline and click the Variables tab
- Add variables with the corresponding values. For example:
- Hostname:
FTP_HOST
/192.168.0.100
- Login:
FTP_LOGIN
/admin
- Password:
FTP_PASS
/buddy1234
- Hostname:
Configuring environment variables
- Now you can use the variables to store access credentials to your deployment server:
Using variables in action
Fields that support ENV VARs
Environment variables are supported across the whole service, but most commonly used in the build actions. You can predict a variable by entering $
at the beginning of the supported field:
Run commands box
Here's the list of the currently supported fields:
Action Name | Supported Fields |
---|---|
Amazon S3 | SourcePath, Remote Path, Tag Objects Value |
AWS CLI | Run Commands |
AWS CLI 2 | Run Commands |
AWS ECS | Source Path |
AWS Lambda Deploy | Source Path |
AWS Lambda Trigger | Payload |
Azure App Service | URL, Login, Password |
Azure CLI | Run Commands |
Azure Storage | Source Path, Remote Path |
Build Android App | Run Commands, Mount Filesystem Path, Mount Container Path, Working dir |
Build Android React Native Application | Run Commands, Mount Filesystem Path, Mount Container Path, Working dir |
Build Docker Image | Name, Value |
Build Flutter App | Run Commands, Mount Filesystem Path, Mount Container Path, Working dir |
Build Ionic app | Mount Filesystem Path, Mount Container Path, Working dir |
Bugsnag | API Key, Version, Revision, Builder Name, Release Stage |
CloudFront | Base URL, Source Path |
Cloudflare | Base URL |
CodeDeploy | Source Path, Bucke tName, Description |
Compress images | Source Path, Destination Path |
Copy files | Source Path, Remote Path |
Custom Build | Run Commands, Mount Filesystem Path, Mount Container Path, Working dir |
Datadog | Event Title, Content, Host, Tags, Aggregation Key |
Datadog Service Check | Hostname, Check |
DigitalOcean Droplet | Source Path, Port, Login, Password, Remote Path, SSH Key Passphrase |
DigitalOcean Spaces | SourcePath, Remote Path |
DigitalOcean Spaces CDN | BaseURL |
Discord | Channel, Attachments, Message |
Dockerfile | Build Arguments |
Dockerfile Linter | Dockerfile, YAML file with ignores |
Elastic Beanstalk | Source, Version, Bucket 1, Environment 2 |
Subject, Attachments, Message | |
ESLint | Mount Filesystem Path, Mount Container Path, Working dir |
Find & replace | Source Path, Replacements |
Firebase | Mount Filesystem Path, Mount Container Path, Working dir |
FTP | Source Path, Hostname, Port, Login, Password, RemotePath |
FTP Download | Hostname, Port, Login, Password, Source Path, Destination Path |
FTPS | Source Path, Hostname, Port, Login, Password, Remote Path |
Function Deploy | |
GCE | Source Path, Hostname, Port, Login, Password, Remote Path |
GCloud CLI | Run Commands |
GCS | SourcePath, RemotePath |
Ghost Inspector | Path |
Git Push | URL, Login, Password |
Gitcrypt lock | |
Gitcrypt unlock | |
Google App Engine | Source Path, Bucket, Version, ImageURL |
Google CDN | BaseURL |
Google Cloud CLI | Run Commands |
Google Cloud Functions | Source Path |
Google Cloud Storage | Source Path, Remote Path |
Google Compute Engine | Source Path, Hostname, Port, Login, Password, Remote Path |
Google Function Trigger | |
Heroku | |
Heroku CLI | Run Commands |
Honeybadger | Environment |
HTTP | EndpointURL, Login, Password, Request headers |
Image compression | Source, Destination |
Kubernetes Apply | Server, Username, Password, Source Path, Prune Whitelist, Grace Period |
Kubernetes CLI | Server, Username, Password, Run Commands |
Run Kubernetes Job | Server, Username, Password, YAML |
Run Kubernetes Pod | Server, Username, Password, YAML |
Set Kubernetes Image | Server, Username, Password, ImageName, Image Tag |
Lambda Deploy | SourcePath |
Lambda Trigger | Qualifier |
Link validator | URL |
Lighthouse | URL |
Local Shell | |
Loggly | Tags |
Monitoring | Environment 3, Application 4 |
MS Teams | Channel email, Title, Attachments from filesystem |
Netlify | |
New Relic | Description, Changelog, Version |
Pass arguments | |
PHP CodeSniffer | Mount Filesystem Path, Mount Container Path, Working dir |
Ping | Host |
Publish APK to Google Play | APK, Main expansion file, Patch expansion file, Service Key, Package name, Mapping file |
Pushbullet | Title, URL, Message |
Push Docker Image | Login, Password, Repository, Tags |
Pushover | Title, URL, URL Title, Message |
Rackspace | Source Path, Remote Path |
Raygun | Access Token, API Key, Version, User, Email, Comment |
Replace | Source Path, Replacements (name) |
Rollbar | Environment, Comment, Username, Rollbar Username |
Rsync | Source Path, Hostname, Port, Login, Password, Remote Path |
Run Docker Image | Login, Password, Image, Version, CMD, Entrypoint |
Run Helm CMDs | Run Commands, Server, Username, Password |
Run next pipeline | Comment |
Sentry | Release Version, Deploy Environment, Release URL, Deploy URL, Repository |
Sentry On-premises | Release Version, Deploy Environment, Release URL, Deploy URL, Repository |
Sign APK | Select the APK, Location, Keystore Password, Key Alias, Output Directory, Output APK Name |
SFTP | SourcePath, Hostname, Port, Login, Password, Remote Path, Private SSH Key, SSH Key Passphrase |
SFTP Download | Hostname, Port, Login, Password, Source Path, Destination Path, Private SSH Key, SSH Key Passphrase |
Shopify | SourcePath |
Slack | Attachments, Message |
Sleep | |
SMS | Message |
S3 Download | Source Path, Destination |
Split tests | Tests Path |
SSH | Source Path, Hostname, Port, Login, Password, RemotePath |
SSL verify | Website URL |
TCP | Host, Port, String To Send, String To Expect |
Theme Kit CLI | Run Commands |
Telegram | Attachments, Message |
UpCloud | Source Path, Port, Login, Password, RemotePath, SSH Key Passphrase |
Visual tests | |
Vultr | SourcePath, Port, Login, Password, Remote Path |
Wait for approval | Question |
WEB | URL, Check For String, Login, Password, Request headers |
WebDAV | Source Path, Hostname, Login, Password |
ZIP | Source Path, Target Path, File Name |
Default environment variables
Buddy populates a number of environment variables during each execution - for example the branch from which you deploy and the ID of the execution. Here is the list of populated variables:
Name | Value |
---|---|
BUDDY | Represents whether the current environment is a Buddy environment |
BUDDY_WORKSPACE_URL | The URL of the workspace |
BUDDY_WORKSPACE_ID | The ID of the workspace |
BUDDY_WORKSPACE_NAME | The ID of the workspace |
BUDDY_WORKSPACE_DOMAIN | The slug of the workspace |
BUDDY_PROJECT_URL | The URL of the project |
BUDDY_PROJECT_NAME | The name of the project |
BUDDY_PROJECT_NAME_ID | The ID of the project |
BUDDY_REPO_SLUG | The slug of the repository |
BUDDY_REPO_SSH_URL | The SSH URL of the repository |
BUDDY_SCM_URL | The URL of the repository synchronized with the project |
BUDDY_SCM_PROVIDER | The name of the Git hosting provider synchronized with the project |
BUDDY_PIPELINE_URL | The URL of the executed pipeline |
BUDDY_PIPELINE_ID | The ID of the executed pipeline |
BUDDY_PIPELINE_NAME | The name of the executed pipeline |
BUDDY_PIPELINE_REF_NAME | The branch/tag/pull request or a wildcard string set in the executed pipeline |
BUDDY_PIPELINE_TRIGGER_MODE | The trigger mode set in the executed pipeline |
BUDDY_PIPELINE_TARGET_SITE_URL | The target website URL |
BUDDY_INVOKER_URL | The URL to the profile of the execution invoker |
BUDDY_INVOKER_ID | The ID of the execution invoker |
BUDDY_INVOKER_NAME | The name of the execution invoker |
BUDDY_INVOKER_EMAIL | The email address of the execution invoker |
BUDDY_INVOKER_AVATAR_URL | The URL of the avatar of the execution invoker |
BUDDY_EXECUTION_URL | The URL of the current execution |
BUDDY_EXECUTION_ID | The ID of the current execution |
BUDDY_EXECUTION_START_DATE | The date of the current execution |
BUDDY_EXECUTION_MODE | The trigger mode used to run the current execution |
BUDDY_EXECUTION_CLEAR_CACHE | Represents whether the cache was purged before the current execution |
BUDDY_EXECUTION_REFRESH | Represents whether the files were uploaded from scratch by the deployment actions in the current execution |
BUDDY_EXECUTION_COMMENT | The comment attached to the current execution |
BUDDY_EXECUTION_BRANCH | The name of the Git branch of the current execution |
BUDDY_EXECUTION_TAG | The name of the Git tag of the current execution (provided the execution is tagged) |
BUDDY_EXECUTION_PULL_REQUEST_ID | The ID of the currently executed pull request |
BUDDY_EXECUTION_PULL_REQUEST_NO | The number of the currently executed pull request |
BUDDY_EXECUTION_PULL_REQUEST_BASE_BRANCH | The name of the Git BASE branch of the currently executed Pull Request |
BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH | The name of the Git HEAD branch of the currently executed Pull Request |
BUDDY_EXECUTION_PREVIOUS_REVISION | The SHA1 hash of the commit of the previous execution |
BUDDY_EXECUTION_PREVIOUS_REVISION_MESSAGE | The commit message of the previously executed revision |
BUDDY_EXECUTION_PREVIOUS_REVISION_SUBJECT | The commit subject of the previously executed revision |
BUDDY_EXECUTION_REVISION | The SHA1 hash of the commit of the current execution |
BUDDY_EXECUTION_REVISION_URL | The URL of the commit of the current execution |
BUDDY_EXECUTION_REVISION_SHORT | The short hash of the commit of the current execution |
BUDDY_EXECUTION_REVISION_MESSAGE | The commit message of the currently executed revision |
BUDDY_EXECUTION_REVISION_SUBJECT | The commit subject of the currently executed revision |
BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL | The email address of the commiter email of the currently executed revision |
BUDDY_EXECUTION_REVISION_COMMITTER_NAME | The email address of the commiter of the currently executed revision |
BUDDY_EXECUTION_CHANGELOG | The list of commits pushed since the last executed revision (one commit per line) |
BUDDY_EXECUTION_CHANGELOG_ADDED | The list of files added since the last executed revision (comma-separated) |
BUDDY_EXECUTION_CHANGELOG_DELETED | The list of files deleted since the last executed revision (comma-separated) |
BUDDY_EXECUTION_CHANGELOG_CHANGED | The list of files changed since the last executed revision (comma-separated) |
BUDDY_EXECUTION_TIME | The total time of the current execution until the action is triggered (in seconds) |
BUDDY_FAILED_ACTION_LOGS | The logs from the action that has failed in the current execution (one entry per line) |
BUDDY_FAILED_ACTION_NAME | The name of the action that has failed in the current execution |
BUDDY_EXECUTION_WARNINGS_COUNT | The total number of warnings that appeared in the current execution |
CI | Represents whether the current environment is another CI environment |
Below you can find a list of exemplary values for the abovementioned variables:
BUDDY=true
BUDDY_WORKSPACE_URL=https://app.buddy.works/myworkspace
BUDDY_WORKSPACE_ID=1
BUDDY_WORKSPACE_NAME=My Workspace
BUDDY_WORKSPACE_DOMAIN=myworkspace
BUDDY_PROJECT_URL=https://app.buddy.works/myworkspace/my-project
BUDDY_PROJECT_NAME=my-project
BUDDY_PROJECT_NAME_ID=my-project
BUDDY_REPO_SLUG=buddyworks/my-project
BUDDY_REPO_SSH_URL=git@github.com:buddyworks/my-project
BUDDY_SCM_URL=https://github.com/buddyworks/my-project
BUDDY_SCM_PROVIDER=GITHUB
BUDDY_PIPELINE_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1
BUDDY_PIPELINE_ID=1
BUDDY_PIPELINE_NAME=Deploy to Production
BUDDY_PIPELINE_REF_NAME=master
BUDDY_PIPELINE_TRIGGER_MODE=CLICK
BUDDY_PIPELINE_TARGET_SITE_URL=https://buddy.works/
BUDDY_INVOKER_URL=https://app.buddy.works/myworkspace/profile/1
BUDDY_INVOKER_ID=1
BUDDY_INVOKER_NAME=Mike Benson
BUDDY_INVOKER_EMAIL=mikebenson@buddy.works
BUDDY_INVOKER_AVATAR_URL=https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/05d20f3d58ce09a3b4e9g3334a810603/w/32/32/AVATAR.png
BUDDY_EXECUTION_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1/execution/5d9dc42c422f5a268b389d08
BUDDY_EXECUTION_ID=1
BUDDY_EXECUTION_START_DATE=2019-01-01T11:27:40.140Z
BUDDY_EXECUTION_MODE=CLICK
BUDDY_EXECUTION_CLEAR_CACHE=false
BUDDY_EXECUTION_REFRESH=false
BUDDY_EXECUTION_COMMENT=My first execution
BUDDY_EXECUTION_BRANCH=master
BUDDY_EXECUTION_TAG=v1.0
BUDDY_EXECUTION_PULL_REQUEST_ID=pull/1
BUDDY_EXECUTION_PULL_REQUEST_NO=1
BUDDY_EXECUTION_PULL_REQUEST_BASE_BRANCH=master
BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH=master/feature1
BUDDY_EXECUTION_REVISION=e5e13f8b7f8d5c6096a0501dc09b48eef05fea96
BUDDY_EXECUTION_REVISION_URL=https://app.buddy.works/myworkspace/my-project/repository/commit/e5e13f8b7f8d5c6096a0501dc09b48eef05fea96
BUDDY_EXECUTION_REVISION_SHORT=e5e13f8
BUDDY_EXECUTION_REVISION_MESSAGE=Create buddy.yml
BUDDY_EXECUTION_REVISION_SUBJECT=Create buddy.yml
BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL=mikebenson@buddy.works
BUDDY_EXECUTION_REVISION_COMMITTER_NAME=Mike Benson
BUDDY_EXECUTION_CHANGELOG=[e5e13f8] Create buddy.yml | mikebenson | 2019-01-01T07:14:58
BUDDY_FAILED_ACTION_NAME=Upload files
Combining variables into phrases
Variables can be combined with other words to create longer phrases than can be used, for example, to automatically name your infrastructure, releases, or sandboxes. However, you need to obey the following rules:
- Before the variable: any character is allowed.
- After the variable: letters, numbers, and footers (
_
) are not allowed.
Correct usage:
release-$BUDDY_EXECUTION_ID-staging
release$BUDDY_EXECUTION_ID:staging
release_$BUDDY_EXECUTION_ID[staging]
Incorrect usage:
release-$BUDDY_EXECUTION_ID_staging (footer)
release-$BUDDY_EXECUTION_IDstaging (letter)
release-$BUDDY_EXECUTION_ID1staging (number)
Passing variables between actions
Passing variables within one pipeline is useful, e.g. when we want to assign file content to a variable and send it in a notification:
Variable passing pipeline example
- The first action builds the application and saves the log output to
logs.txt
. - In case the build fails, the Local Shell action assigns the content of
logs.txt
to a variable usingexport LOGS=$(cat log.txt)
. - The logs are then sent to a Slack channel with
$LOGS
as the message content.
Passing variables between executions
You can pass the values of variables between executions as well. The values can be saved in one execution and then used in another one, e.g. you can set a variable with the version type and increment it in every execution.
Passing variables between pipelines
You can pass a variable between pipelines using the Run next pipeline action:
- Go into the Variables tab in the action details.
- Define the name of the variable and the value to pass:
Variables tab
Resetting variables between executions
To reset settable variables between pipeline executions, you can add an action with a command that will clear the value of the variable (preferably at the beginning or at the end of the pipeline):
export mySettableEnv=
$
Reset variable command
Passing variables on execution start
You can parameterize your execution using the Pass arguments action - it will pause the pipeline and wait for your input to proceed:
Pass arguments window