Free Pack
Download BuildMaster Free Trial

Common Uses for Variables

by Olivia Glenn-Han, on Mar 17, 2015 1:00:00 PM

When used in different ways, BuildMaster variables can be an extremely powerful tool in creating an automated, repeatable deployment process. The following are some common uses for variables.

Setting a Global Constant for Use Anywhere in BuildMaster

Yes, a "constant variable" is an oxymoron, but you can use System variables to create a key/value pair that can be replaced throughout the whole system.

Pulling Code from Different Branches

There are two fundamental branching strategies that can be used to develop software: branch by exception (e.g., a new release/feature branch and merge into trunk for deployment) and branch by rule (e.g., deployed branch becomes the new trunk).

To support these patterns within BuildMaster, a Release variable can be used to determine which branch to build from. For example, in your Get Latest from source control action, you can use variables in the source path to pull from a branch. When building BuildMaster extensions, we use the following: Get latest from "bmx-%APPNAMELOWER%|%BUILD-SOURCE%:", where BUILD-SOURCE is a release variable that points to the branch on GitHub to build.

Optional Behavior During a Particular Execution

There are times during deployment scenarios where a certain group of actions only needs to be run sometimes. This can be accomplished with really any scope of variable but most commonly either a Build variable or a Promotion variable. Combined with a "Variable Value" predicated on an action group, that group will only execute its actions if the variable is set for your particular build, promotion, release, or whatever scope the variable happens to be.

Note that running certain action groups during an execution can also be accomplished with a combination of multiple deployables and predicates, but deployables should represent individual components of your application and not "optional" behavior such as the examples listed below.

Typical examples of this scenario include:

  • rebuilding the integration database from scratch on a build to integration
  • restoring a database from production when building to integration
  • determining whether the code was pulled from a branch
  • whether to run unit tests or not

Setting the Build Configuration for Your Project for Each Build

With a Build variable, for example, you could change the behavior of MSBuild to set the build configuration to the variable %BUILD-CONFIG%, whose value is selected from a dropdown at build time to either "Debug" or "Release," which in turn would build that configuration in the Integration environment. Combined with a "Variable Value" promotion requirement, you could block promotion beyond Testing, for example, unless that value is set to "Release" to ensure that Debug builds never make it out of your testing environment.

Changing a Path for a Particular Server in a Server Group

When deploying to server groups, it's possible that one of the servers is a "one-off" with a different deployment path or configuration. By setting a Server variable, you could control the path on that single server by overriding the default value of that variable just for that server.

Auto-deployment to the Next Environment

With the Auto-Promote Build trigger, BuildMaster can promote a build to the next environment automatically by checking the value of a variable to determine if it should do so.

… Anything!

Variable types and editors are extensible and can be created custom to fulfill whatever variable deployment scenario you can imagine.


Inedo DevOps tools maximize developer time, minimize release risk, and empower stakeholders to bring their vision to life faster. All with the people and technology you have right now. 

Download BuildMaster Free Trial


Related Posts

About Inedo

Inedo is a software product company bringing you the "tech behind the tech."

Makers of Windows-first, enterprise DevOps tools BuildMaster CI/CD, ProGet private package management, and Otter IaC. Maximize developer time, minimize release risk, and empower stakeholders to bring their vision to life faster, all with the people and technology you have right now.

Follow us on social media

Follow Inedo on YouTube Follow Inedo on Facebook Follow Inedo Twitter New call-to-action

Free e-books

Free PowerShell Book NuGet for the Enterprise Guide Jenkins CICD Guide Free CICD Book Free dotnet book free IaC book