Environment variables in commit messages

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:

bash
“My message —env MY_VAR=VALUE“$

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

bash
“My message —env MY_VAR='VALUE WITH SPACES'“$
Hint
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:

Image loading...Example 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:

Image loading...Condition 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.

Image loading...Variable in commit message

Warning
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.
Jarek Dylewski

Jarek Dylewski

Customer Support

A journalist and an SEO specialist trying to find himself in the unforgiving world of coders. Gamer, a non-fiction literature fan and obsessive carnivore. Jarek uses his talents to convert the programming lingo into a cohesive and approachable narration.

Oct 31st 2019
Share