Skip to content
v2.6

(Environment) Variables ​

Introduction ​

With environment variables, you can have variables whose contents depend on the environment or stage you work in. Rulecube has these environments:

  • test
    This is the development environment where you create and maintain rulesets.
  • demo
    This is the quality assurance environment where testers and users test rulesets.
  • app
    This is the live environment where users work with rulesets.

And this is the correlated development process you usually follow for your rulesets:

  1. You create and maintain your rulesets in the test environment.
  2. When ready, you export your ruleset and import it into the demo environment.
  3. The persons responsible for quality assurance test the ruleset in the demo environment.
  4. You correct the issues they find in test and deploy them to demo until you solved all issues, and the ruleset is ready to go live.
  5. You export your ruleset and import it into the app environment where users work with it.

A variable with a different value for each environment ​

Now, let's assume that a ruleset calls an external API for financial data, and the corresponding URL varies per environment:

EnvironmentAPI URL
testdev.findata.com
demotest.findata.com
appapi.findata.com

One solution to this is to create a constant for the URL and change the constant value each time you deploy your ruleset to a different environment. But this is cumbersome and error-prone. So it's much better to use an environment variable because you only have to set the environment-specific values for the same variable once. And when you deploy your ruleset, Rulecube automatically chooses the correct variable value for the environment it's running in.

For example, you create an environment variable named FinDataURL and assign it the appropriate values in each environment:

EnvironmentFinDataURL
testhttps://dev.findata.com
demohttps://test.findata.com
apphttps://api.findata.com

Now, when you run in test, Rulecube automatically picks the dev.findata.com URL, and when you run in app, Rulecube selects the api.findata.com URL. Fully automated, without any intervention from your side.