Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[che-dev] adding environment variables support to Builder.class

Hi,

We, here at SAP are developing Che Builder that should be able to execute build requests while the execution relies on environment variables.

i.e. the commands that are going to be executed by the builder read some information from the  environment variables.

Hence the environment variables should be updated before the build execution dynamically for every build.

 

Following current implementation the information could be passed to the builder using the BuildRequest, but as I see it, update of the environment variables before the build execution is missing.

So I'm proposing  to add  the following method to the Builder.class

 

public Map<String, String> getEnvironmentVariables (){

                return new HashMap<String, String>();

}

 

Any implementing builder class can override this method , by default it will be empty .

so that in Line 440 in Builder.class ,the code could be changed to the following :

 

ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine.toShellCommand()).directory(

                            configuration.getWorkDir()).redirectErrorStream(true);

 

Map<String, String> env = processBuilder.environment();

env. putAll(getEnvironmentVariables());

 

Process process = processBuilder.start();

 

 

 

This way the command executed by the builder will be able to use the environment variables passed in to the builder using the BuildRequest.

Do you agree on this solution? Please provide any insights or suggestion,  I will prepare a pull request shortly.

 

Thanks

 

Best Regards,

Dany Shapiro.

DI Cloud Exp DevX | SaaS Extensions &  Ecosystem Team | SAP Labs Israel | 15 Hatidhar st. | Raanana 43665, Israel

T +972-(0)9-777-5201

SAP_logo_small

 

 


Back to the top