Environment variables in commit messages

October 31, 2019

Environment variables in commit messages

Environment variables (or ENV VARs) greatly expand the scope of things that can be achieved with Buddy. Although the most common use case is keeping sensitive configuration data safe and sound (server credentials, passwords, SSH keys, etc.), you can use them, for example, to:

All of the above provide developers with extra control over the delivery process. Additionally, with this week's release it is possible to pass ENV VARs to the execution directly from the terminal using commit commands:

“My message —env MY_VAR=VALUE“$

Values with spaces should be put in a pair of single quotes within the commit message:

“My message —env MY_VAR='VALUE WITH SPACES'“$
ENV VARs in commits are created with the EXECUTION scope, which means they have higher priority (i.e. overwrite)8 variables with action, pipeline, project, and workspace scopes. Learn more about scopes in variables.

Example use case

Variables in commit messages can be used to trigger pipeline actions on specific conditions. Here we have a pipeline which runs Yarn on repository files, deploys them to Netlify, and notify clients of the new version via Slack. The pipeline is configured to run on every push to the master branch:

Example pipelineExample pipeline

However, sometimes we need to release a hotfix which doesn't need informing the client. In this case, we can configure a specific condition in the notification action:

Condition configurationCondition configuration

This means the action will always run unless the variable $SEND_SLACK is set to NO in the execution. So, if we want to test and deploy the commit without sending the message to the client, all we need to do is add --env SEND_SLACK=NO to the commit message.

Variable in commit messageVariable in commit message

Buddy is 100% customer-driven. If there’s a feature or integration you miss, let us know in the comments below or directly at support@buddy.works.


Alexander Kus

Alexander Kus

Customer Success Manager

A story-teller and conversation-lover, Alexander decided to invest his skills to help his friends at Buddy transform the cold language of patch notes into exciting narratives. Also: an avid gamer, hip-hop DJ, Liverpool FC fan, absentminded husband, and the father of two.