Inject env vars to Jenkins programmatically

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Inject env vars to Jenkins programmatically


I am trying to inject environment variables to Jenkins build from my internal Maven plugin in Java. 

What did I do? 

I added the Jenkins code Maven dependency to my plugin an implemented the relevant interface: 

public class Test implements EnvironmentContributingAction{


    public void buildEnvironment(Run<?, ?> run, EnvVars env) {

                EnvironmentContributingAction.super.buildEnvironment(run, env);


Now - I'm trying to call this class from a different class: 

EnvVars envVars = new EnvVars();

envVars.put("myvar", "myvalue");

Test test = new Test();

test.buildEnvironment(???? , envVars);

What is the "Run" class? What should I add into this method so it will run from the build object in Jenkins? 

Any Github example or snippet will be much appreciated.


This message may contain confidential and/or privileged information. 
If you are not the addressee or authorized to receive this on behalf of the addressee you must not use, copy, disclose or take action based on this message or any information herein. 
If you have received this message in error, please advise the sender immediately by reply email and delete this message. Thank you.

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 [hidden email].
To view this discussion on the web visit
For more options, visit