svyCloud
Use the svyCloud scope in Servoy Cloud to detect the active environment type, set tenant name and value, and configure session idle timeout per client.
The svyCloud scope provides three things: a way to identify which environment your application is running in, and two functions for setting tenant-specific metadata on the current client session.
Environment detection
CLOUD_ENVIRONMENT_TYPES
A constant object with all supported environment types. Always reference it via the full scope path scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES — using a shorthand or local variable will not work in Servoy.
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.PRODUCTION
'prod'
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.PRE_PRODUCTION
'preprod'
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.USER_ACCEPTANCE
'uat'
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.DEVELOP
'dev'
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.DEMO
'demo'
scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.E2E
'e2e'
getCurrentEnvironment()
Returns the current environment type as a string value from scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.
When running inside Servoy Developer, this always returns 'dev'. In a deployed cloud environment, the value comes from the ENVIRONMENT system property set by the cloud infrastructure.
var env = scopes.svyCloud.getCurrentEnvironment();
if (env === scopes.svyCloud.CLOUD_ENVIRONMENT_TYPES.PRODUCTION) {
// production-only logic
}Tenant management
Tenant information is stored as client info on the current session. Servoy Cloud uses this to identify which tenant a session belongs to — for example, in multi-tenant setups where a single cloud environment serves multiple customers.
setTenantName(value)
Sets the tenant name for the current client session.
value
String
The tenant name to associate with this session
setTenantValue(value)
Sets the tenant value (typically a tenant ID or key) for the current client session.
value
String
The tenant value to associate with this session
setMaxIdleTime(timeInMinutes)
Sets the maximum idle time for the current client session. When the session has been idle for this many minutes, Servoy Cloud will disconnect it and free up resources.
timeInMinutes
Number
Idle timeout in minutes
Call this during session initialization — for example in the onSolutionOpen method of your solution's preImport module — to apply a tenant-specific or role-specific timeout.
Build and version info
These functions return metadata injected by the Servoy Cloud pipeline. They return null if the values are not set (for example, when running in developer mode).
scopes.svyCloud.getJenkinsBuildNr()
Number
The Jenkins build number
scopes.svyCloud.getJenkinsBuildDate()
Date
The Jenkins build date
scopes.svyCloud.getSvnRevision()
String
The SVN revision at build time
scopes.svyCloud.getGitCommit()
String
The Git commit hash at build time
scopes.svyCloud.getGitBranch()
String
The Git branch at build time
scopes.svyCloud.getSVNBranch()
String
The SVN branch at build time
These are useful for displaying version information in your application or for logging.
See also: svyDataSeed for importing and exporting database seed data, and svyDeployUtils for database migrations and deployment utilities.
Last updated
Was this helpful?