Hello

I have created this plugin 
(https://github.com/jenkinsci/global-pre-script-plugin).
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

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/9487c061-7c17-4f83-b804-6e6ce9d502e2%40googlegroups.com.

Reply via email to