Adding environment variables support to Builder.class #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I am 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);
HashMap<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.
Thanks
Dany.