Setting envvars in Jenkins plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting envvars in Jenkins plugin

Константин Валерьевич

I'm trying to develop new Jenkins plugin. I've started from hello-world archetype provided by Jenkins. My plugin works fine!

Bun now i want to put some environment variables from my plugin. I've used whis code to do it

public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) {

    ...
    EnvVars envVars = run.getEnvironment(listener);
    envVars.put("SOME_VARIABLE", "SOME_VALUE");
    ...

}

But it don't work. I'm trying to use this variable on next build step and got nothing. I've googled it and there isn't quite clear discriptions. Source codes of existing plugins (EnvInject, etc) also doesn't help.

What am i doing wrong? Can anybody provide me some samples?

--
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 https://groups.google.com/d/msgid/jenkinsci-dev/a060926d-bd1a-4511-a3ae-ea54109722a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Setting envvars in Jenkins plugin

Daniel Beck

> On 28. Dec 2017, at 17:08, Konstantin <[hidden email]> wrote:
>
> But it don't work. I'm trying to use this variable on next build step and got nothing. I've googled it and there isn't quite clear discriptions. Source codes of existing plugins (EnvInject, etc) also doesn't help.

Not having looked at the code, you're probably getting your own copy of the EnvVars.

One of these should get you there:
https://jenkins.io/doc/developer/extensions/jenkins-core/#environmentcontributor
https://jenkins.io/doc/developer/extensions/jenkins-core/#buildwrapper
https://jenkins.io/doc/developer/extensions/jenkins-core/#runlistener

--
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 https://groups.google.com/d/msgid/jenkinsci-dev/C41D3D54-D6E6-4563-A563-5D5AD9C99C71%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.