Access environment variables from Optimize plugin


#1

hi - when building a custom plugin for Optimize, e.g https://docs.camunda.org/optimize/develop/technical-guide/plugins/engine-rest-filter, is there a way to access the environment variables defined in the environment yaml ?

Any documentation or snippets of code appreciated.

thanks


#2

Hey Eleco!

there is not yet an official way, however you could add the optimize-backend-2.x.x.jar as a local dependency to your project and would then be able to use and inject the internal ConfigurationService like this.

import org.camunda.optimize.service.util.configuration.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;

public class EngineRestFilterWithConfig implements EngineRestFilter {

@Autowired
private ConfigurationService configurationService;

@Override
public void filter(ClientRequestContext requestContext, String engineAlias, String engineName) throws IOException {
 System.out.println(configurationService.getContainerHost());
}

}

Assuming you only need access to already defined configuration entries you could do it like that, but you won’t be able to access any custom entries.

What is your use case if I may ask?

Sebastian


#3

thanks @Sebastian_Bathke

our use case - we’d like to configure the way optimize authenticates against the bpmn engine, based on custom parameters stored in the environmnent.yaml. The alternative being to use system properties if custom entries are not accessible.