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:

  1. Workspace - available for all projects and pipelines. Configured in the workspace Preferences.
  2. Project - available for all pipelines in the project. Configured in the Project Options.
  3. Pipeline - available only for the pipeline where was created (eg. production server details). Configured in the pipeline details.
  4. Action - available only for the actions where the variable was defined

Each subsequent tier will overwrite the value from the higher tier. For example, if you have two same variables - one defined on the workspace level and another on the pipeline level - Buddy will use the pipeline value in that pipeline, and the workspace value in the rest of the account.

Workspace environment variables

Example Usage

Let's configure some variables to encrypt access to an FTP server:

  1. Go to your deployment pipeline and click the Variables tab
  2. Add variables with the corresponding values. For example:
    • Hostname: FTP_HOST / 192.168.0.100
    • Login: FTP_LOGIN / admin
    • Password: FTP_PASS / buddy1234

Configuring environment variables

  1. 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 NameSupported Fields
Amazon S3SourcePath, Remote Path, Tag Objects Value
AWS CLIRun Commands
AWS CLI 2Run Commands
AWS ECSSource Path
AWS Lambda DeploySource Path
AWS Lambda TriggerPayload
Azure App ServiceURL, Login, Password
Azure CLIRun Commands
Azure StorageSource Path, Remote Path
Build Android AppRun Commands, Mount Filesystem Path, Mount Container Path, Working dir
Build Android React Native ApplicationRun Commands, Mount Filesystem Path, Mount Container Path, Working dir
Build Docker ImageName, Value
Build Flutter AppRun Commands, Mount Filesystem Path, Mount Container Path, Working dir
Build Ionic appMount Filesystem Path, Mount Container Path, Working dir
BugsnagAPI Key, Version, Revision, Builder Name, Release Stage
CloudFrontBase URL, Source Path
CloudflareBase URL
CodeDeploySource Path, Bucke tName, Description
Compress imagesSource Path, Destination Path
Copy filesSource Path, Remote Path
Custom BuildMount Filesystem Path, Mount Container Path, Working dir
DatadogEvent Title, Content, Host, Tags, Aggregation Key
Datadog Service CheckHostname, Check
DigitalOcean DropletSource Path, Port, Login, Password, Remote Path, SSH Key Passphrase
DigitalOcean SpacesSourcePath, Remote Path
DigitalOcean Spaces CDNBaseURL
DiscordChannel, Attachments, Message
DockerfileBuild Arguments
Dockerfile LinterDockerfile, YAML file with ignores
Elastic BeanstalkSource, Version, Bucket 1, Environment 2
EmailSubject, Attachments, Message
EslintMount Filesystem Path, Mount Container Path, Working dir
Find & replaceSource Path, Replacements
FirebaseMount Filesystem Path, Mount Container Path, Working dir
FTPSource Path, Hostname, Port, Login, Password, RemotePath
FTP DownloadSFTP Download
FTPSSource Path, Hostname, Port, Login, Password, Remote Path
Function Deploy
GCESource Path, Hostname, Port, Login, Password, Remote Path
GCloud CLIRun Commands
GCSSourcePath, RemotePath
Ghost InspectorPath
Git PushURL, Login, Password
Gitcrypt lock
Gitcrypt unlock
Github ReleaseTag Name, Target Commitish, Release Name, Release Description, Source Path, Asset Label
Google App EngineSource Path, Bucket, Version, ImageURL
Google CDNBaseURL
Google Cloud CLIRun Commands
Google Cloud FunctionsSource Path
Google Cloud StorageSource Path, Remote Path
Google Compute EngineSource Path, Hostname, Port, Login, Password, Remote Path
Google Function Trigger
Heroku
Heroku CLIRun Commands
HoneybadgerEnvironment
HTTPEndpointURL, Login, Password, Request headers
Image compressionSource, Destination
Kubernetes ApplyServer, Username, Password, Source Path, Prune Whitelist, Grace Period
Kubernetes CLIServer, Username, Password, Run Commands
Run Kubernetes JobServer, Username, Password, Yaml
Run Kubernetes PodServer, Username, Password, Yaml
Set Kubernetes ImageServer, Username, Password, ImageName, Image Tag
Lambda DeploySourcePath
Lambda TriggerQualifier
Link validatorURL
LighthouseURL
Local Shell
LogglyTags
MonitoringEnvironment 3, Application 4
MS TeamsChannel email, Title, Attachments from filesystem
Netlify
New RelicDescription, Changelog, Version
Pass arguments
PHP CodeSnifferMount Filesystem Path, Mount Container Path, Working dir
PingHost
Publish APK to Google PlayAPK, Main expansion file, Patch expansion file, Service Key, Package name, Mapping file
PushbulletTitle, URL, Message
Push Docker ImageLogin, Password, Repository, Tags
PushoverTitle, URL, URL Title, Message
RackspaceSource Path, Remote Path
RaygunAccess Token, API Key, Version, User, Email, Comment
ReplaceSource Path, Replacements (name)
RollbarEnvironment, Comment, Username, Rollbar Username
RsyncSource Path, Hostname, Port, Login, Password, Remote Path
Run Docker ImageLogin, Password, Image, Version
Run Helm CMDsRun Commands, Server, Username, Password
Run next pipelineComment
SentryRelease Version, Deploy Environment, Release URL, Deploy URL, Repository
Sentry On-premisesRelease Version, Deploy Environment, Release URL, Deploy URL, Repository
Sign APKSelect the APK, Location, Keystore Password, Key Alias, Output Directory, Output APK Name
SFTPSourcePath, Hostname, Port, Login, Password, Remote Path
SFTP DownloadHostname, Port, Login, Password, Source Path, Destination Path
ShopifySourcePath
SlackAttachments, Message
Sleep
SMSMessage
S3 DownloadSource Path, Destination
Split testsTests Path
SSHSource Path, Hostname, Port, Login, Password, RemotePath
SSL verifyWebsite URL
TCPHost, Port, String To Send, String To Expect
Theme Kit CliRun Commands
TelegramAttachments, Message
UpcloudSource Path, Port, Login, Password, RemotePath, SSH Key Passphrase
Visual tests
VultrSourcePath, Port, Login, Password, Remote Path
Wait for approvalQuestion
WEBURL, Check For String, Login, Password, Request headers
WebDAVSource Path, Hostname, Login, Password
ZIPSource Path, Target Path, File Name
1-4 You cannot type there anything on the front-end. Add this action using REST API or YAML - used variables should work there with no problems.

Some fields are HTML textareas and do not support variable suggestions, e.g. message fields in notifications. They do support ENV VARs perfectly fine, however.

You can also use multi-line environment variables in the listed actions.

If you didn't find your action here or the required field is unsupported, let us know on the live-chat or drop a line at support@buddy.works.

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:

BUDDY
BUDDY_WORKSPACE_URL
BUDDY_WORKSPACE_ID
BUDDY_WORKSPACE_NAME
BUDDY_WORKSPACE_DOMAIN
BUDDY_PROJECT_URL
BUDDY_PROJECT_NAME
BUDDY_PROJECT_NAME_ID
BUDDY_REPO_SLUG
BUDDY_REPO_SSH_URL
BUDDY_SCM_URL
BUDDY_SCM_PROVIDER
BUDDY_PIPELINE_URL
BUDDY_PIPELINE_ID
BUDDY_PIPELINE_NAME
BUDDY_PIPELINE_REF_NAME
BUDDY_PIPELINE_TRIGGER_MODE
BUDDY_PIPELINE_TARGET_SITE_URL
BUDDY_INVOKER_URL
BUDDY_INVOKER_ID
BUDDY_INVOKER_NAME
BUDDY_INVOKER_EMAIL
BUDDY_INVOKER_AVATAR_URL
BUDDY_EXECUTION_URL
BUDDY_EXECUTION_ID
BUDDY_EXECUTION_START_DATE
BUDDY_EXECUTION_MODE
BUDDY_EXECUTION_CLEAR_CACHE
BUDDY_EXECUTION_REFRESH
BUDDY_EXECUTION_COMMENT
BUDDY_EXECUTION_BRANCH
BUDDY_EXECUTION_TAG
BUDDY_EXECUTION_PULL_REQUEST_ID
BUDDY_EXECUTION_PULL_REQUEST_NO
BUDDY_EXECUTION_PULL_REQUEST_BASE_BRANCH
BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH
BUDDY_EXECUTION_PREVIOUS_REVISION
BUDDY_EXECUTION_PREVIOUS_REVISION_MESSAGE
BUDDY_EXECUTION_PREVIOUS_REVISION_SUBJECT
BUDDY_EXECUTION_REVISION
BUDDY_EXECUTION_REVISION_URL
BUDDY_EXECUTION_REVISION_SHORT
BUDDY_EXECUTION_REVISION_MESSAGE
BUDDY_EXECUTION_REVISION_SUBJECT
BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL
BUDDY_EXECUTION_REVISION_COMMITTER_NAME
BUDDY_EXECUTION_CHANGELOG
BUDDY_EXECUTION_CHANGELOG_ADDED
BUDDY_EXECUTION_CHANGELOG_CHANGED
BUDDY_EXECUTION_CHANGELOG_DELETED
BUDDY_EXECUTION_TIME
BUDDY_FAILED_ACTION_LOGS
BUDDY_FAILED_ACTION_NAME

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=MANUAL
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=MANUAL
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

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

  1. The first action builds the application and saves the log output to logs.txt.
  2. In case the build fails, the Local Shell action assigns the content of logs.txt to a variable using export LOGS=$(cat log.txt).
  3. The logs are then sent to a Slack channel with $LOGS as the message content.

Make sure to set the variable to Settable, otherwise it will not be possible to change its value.

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:

  1. Go into the Variables tab in the action details.
  2. Define the name of the variable and the value to pass: Variables tab

You can assign any variable from the target pipeline as the value.

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 argunents window