Skip to content
v2.6

Create an environment variable ​

Procedure ​

Let's bring the example into practice:

Step 1: Create the environment variable in test and use it in the ruleset ​

  1. If you're not in your Rulecube test environment, move over to test.

  2. Create a ruleset named EnvExample.

  3. Click Variables from the top menu.
    ↳ The general Environment variables page opens.

  4. Click Add variable.
    ↳ Rulecube adds a new environment variable row.

  5. In the Name field, enter FinDataURL.

  6. In the Value field, enter https://dev.findata.com.

  7. Click Save.

  8. Now, open the ruleset where you want to use the environment variable.

  9. Click Environment variables from the menu at the left.
    ↳ The ruleset Environment variables page opens:\

  10. Select the FinDataURL checkbox.

  11. Create a rule named ShowURL and set its Expression to:

    javascript
    FinDataURL

    ↳ This rule just returns the content of the environment variable, which is fine for illustrating how environment variables work, but in practice, a rule Expression like this is more realistic:

    javascript
    Http.request(FinDataURL + "?region=europe").data.data
  12. Click Save.

  13. Click Try it out.

  14. Click Execute.
    ↳ The Sandbox output shows "https://dev.findata.com".

Step 2: Create the environment variable in demo ​

  1. Move over to your demo environment.
  2. Click Variables from the top menu.
  3. Click Add variable.
  4. In the Name field, enter FinDataURL.
  5. In the Value field, enter https://test.findata.com.
  6. Click Save.

Step 3: Create the environment variable in app ​

  1. Move over to your app environment.
  2. Click Variables from the top menu.
  3. Click Add variable.
  4. In the Name field, enter FinDataURL.
  5. In the Value field, enter https://api.findata.com.
  6. Click Save.

Step 4: Deploy your ruleset ​

  1. Move back to your test environment.
  2. Open the EnvExample ruleset.
  3. Click Export.
    ↳ The Export pop-up opens.
  4. Click OK.
    ↳ Rulecube exports the ruleset as a JSON file into the default download folder on your workstation.
  5. Move over to your demo environment.
  6. Click Import.
    ↳ The Import ruleset pop-up opens.
  7. Open your file manager and navigate to your default download folder.
  8. Drag the exported ruleset JSON file and drop it on the Upload (or drag) ruleset data file section of the Import ruleset pop-up.
  9. Click Upload.
    ↳ Rulecube imports the ruleset and shows the General settings page for the ruleset.
  10. Click Try it out.
  11. Click Execute.
    ↳ The Sandbox output now shows "https://test.findata.com" as the value of the FinDataURL environment variable.

And you can do the same deployment steps for your app environment.