Expose a new global environment variable

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

Expose a new global environment variable

Miguelangel Fernandez
Hi,

I'm working on a Jenkins plugin and I have a need to make a new environment variable available to all jobs in Jenkins.
Sort of like a Jenkins global environment variable, or maybe exactly like that. I'm not sure. I just need it to be available to any script.

I already capture the value for this environment variable in one of the entries of my plugin's config.jelly file so it would feel like double work for the admin to also have to set it under "Manage Jenkins>Configure System>Global properties"

Then, as a second step, and thinking of maybe exposing others in the future, how should I go about name-spacing these? Sort of the way there are the env, params, docker, currentBuild environment variables. What should I extend in order to have my own name-spaced env vars? e.g.: foo.MY_VAR_1, foo.MY_VAR_2

Can anyone point me in the right direction?

Thank you,

                                              Miguelángel Fernández M.

Life is what happens to you while you're busy making other plans.

                                                                                    --John Lennon.

--
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/CAK2td26%2BR69fBNa8bBStK%2Bazv_irmkRw5Yn4a1L0FSe%2BPpyigg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Expose a new global environment variable

Jesse Glick-4
On Wed, Oct 11, 2017 at 8:25 AM, Miguelangel Fernandez
<[hidden email]> wrote:
> I'm working on a Jenkins plugin and I have a need to make a new environment
> variable available to all jobs in Jenkins. Sort of like a Jenkins global
> environment variable, or maybe exactly like that. I'm not sure. I just need
> it to be available to any script.

Actual environment variable?

http://javadoc.jenkins.io/hudson/model/EnvironmentContributor.html

> how should I go about name-spacing these? Sort of the way there are the env,
> params, docker, currentBuild environment variables.

These are not environment variables. They are global variables
accessible to Groovy-based Pipeline scripts. Unrelated extension
point.

http://javadoc.jenkins.io/workflow-cps/org/jenkinsci/plugins/workflow/cps/GlobalVariable.html

(Which I do not really recommend you implement. Consider a different design.)

--
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/CANfRfr1rJyaZz7C9D5bVMHo%3DEWB2tmgKG%3DNvCxae6%3D7PVrs0Zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.