Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment Variables in Hybris local.properties

Tags:

I'm wondering if, in a Hybris properties file, there is a way to reference environment variables.

For example, in local.properties: my.property = ${MY_ENVIRONMENT_VARIABLE}

My searching has concluded that this is possible in Spring, but doesn't appear to work in Hybris.

Any thoughts would be appreciated.

like image 944
rohrlach Avatar asked Jan 17 '17 20:01

rohrlach


People also ask

What is local properties in hybris?

The local. properties file is a working copy of the project. properties file, located in the <HYBRIS_CONFIG_DIR> directory. It allows you to override default settings from the project.

What is SAP environment variable?

Environment Variables are widely used in SAP Systems to partially configure an application server or components of it. You may also be asked by a developer to set an environment variable to turn off/on functionality within a process in order to activate alternative code paths for error analysis.

What configuration file has the highest priority in hybris?

properties files in each extension: each Hybris extension has its own configuration file. The properties defined here are available only for the extension, it belongs to. We define the properties, which are to be used only in this extension. Properties specified will be with higher priority than project.


2 Answers

It's possible to access to environment variables within hybris. A partner of my company found out this deep down in hybris documentation:

Platform allows you to specify properties also as environment variables

# security: make the platform *abort startup* if no one overrides the settings below
db.url=<CHANGE_ME>
db.username=<CHANGE_ME>
db.password=<CHANGE_ME>
# security: end

The special property value has been introduced exactly for such use cases where administrators want to ensure that: a) files do not contain sensible settings, and b) the system doesn't start up if those settings haven't been overridden.

On the server, those settings are to be exposed as environment variables just before starting Platform:

 foo$ export y_db_url=jdbc:mysql://my.secret-db-host.com/AlfavaMetraxis?useConfigs=maxPerformance&characterEncoding=utf8
 foo$ export y_db_username=Amy
 foo$ export y_db_password=Rory
 foo$ ./hybrisserver.sh start
...

As you can see, settings need to be prefixed and escaped in order to work as environment variable.

https://help.sap.com/viewer/a74589c3a81a4a95bf51d87258c0ab15/1905/en-US/8b8e13c9866910149d40b151a9196543.html?q=CHANGE_ME

Hope this is useful for you.

like image 106
cbelizon Avatar answered Sep 24 '22 10:09

cbelizon


I found this related to your question on Hybris Experts. Hope it helps.

It is not possible to access shell environment variables inside local.properties file. As a workaround you can do echo "my.property = $MY_ENVIRONMENT_VARIABLE" >> local.properties before starting platform.

like image 29
Sanchit Khera Avatar answered Sep 24 '22 10:09

Sanchit Khera