Hello
The plugin allows to inject variables at the start of any build using a groovy script. It is working very fine.
What I want to improve:
- if the variable was already defined in "manage jenkins -> configure system -> environment variable", injecting a variable with the same name, does not update the value
e.g:
1) environment variable defined in configure system:
Name: MY_GLOBAL_VAR
Value: alfa
2) now, in a job:
- when the build starts, the global-pre-inject plugin injects value 'beta' in MY_GLOBAL_VAR
Value: beta
- when a build step of type execute shell is added:
echo "MY_GLOBAL_VAR: $MY_GLOBAL_VAR"
- the build console log result:
MY_GLOBAL_VAR: alfa
issue: the value was overwritten again after the plugin did it
What I am looking for:
Could
you tell me where I should inject the value of a variable so it can
replace a variable with the same name set in "manage jenkins ->
configure system -> environment variables", when a build starts?
Please be specific, I am new to jenkins internals
More info:
- I am currently injecting properties overriding setUpEnvironment of RunListener and returning
return new Environment() {
@Override
public void buildEnvVars(Map<String, String> env) {
env.putAll(groovyMapEnvVars);
}
};
- I can also inject new values with, e.g. :
EnvironmentContributor.all().add(1, new EnvironmentContributor() {
@Override
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {
envs.put("NEW_VAR", "somevalue");
}
});
Thanks in advance