Get Release Environment

For Teneo developers, it is often very useful to know from which release environment comes the request. For example, you have a flow in development and not ready to be available for the public users, you need to prevent it from being triggered in Production environment; or you use a specific API only when in the Production environment to avoid sending over purchases from testing users; or you want the output text contains extra information for debugging only in the Try out panel.

The following code will return the current release environment and store the value (dev, qa or production) in variable sReleaseEnvironment which need to be defined as a Global variable. If it is a request from Try out, this variable will get the value tryout. This code should be placed in Globals > Scripts > Begin Dialog .

sReleaseEnvironment = engineAccess.getProperty("servletContextParameters.release_environment")?:"tryout"

If you are using Dialog Tester (a regression testing tool running on DEV or QA environment) and you want to distinguish between the requests from Dialog Tester and from the normal DEV or QA environment, please use the following code to overwrite the value of the variable sReleaseEnvironment with dt.

def callback = engineEnvironment.getParameter("callback")
if(callback == "fakeFunction"){
	sReleaseEnvironment = "dt"
}

The code in this post is an example on how you can get the current release environment in your Teneo solution. I hope this code example comes in handy for your project!

1 Like

You might want to add here the special case we had on our project, which we solved with excellent support from Alexander. Our project uses multiple dev environments which are impossible to differentiate using this method alone.
Using this call, you receive a unique path for each environment:
engineEnvironment.getRequestURI()

1 Like

Thanks, Fred, for sharing this additional use case here :slight_smile:

1 Like