Global environmental variables

44 views
Skip to first unread message

Peter Berghold

unread,
Oct 16, 2015, 2:57:13 PM10/16/15
to jenkins...@googlegroups.com
Riddle me this Batman.

Is there a way in Jenkins to set a global value that build jobs can access in a shell? 

Reason I ask is I'm about to create a build job that sets up files for release by gathering a host of modules, staging them and then creating not one but two tarballs for distribution.   I need to designate what the build tag is to help name the tarballs.

modules-{TAG}-{SEMANTIC VERSION}-release.tar.gz

I'd like the to set the TAG and SEMANTIC VERSION in one place and have it carry everywhere....

John Mellor

unread,
Oct 16, 2015, 3:14:06 PM10/16/15
to jenkins...@googlegroups.com

I write out a file containing the globals and then source it wherever required.  For downstream jobs, I have to make the file an artifact, so it gets copied to the master node, and then use the Copy-To-Slave plugin to pull it over to the current node.

 

P.S, all of my builds use various forms of freestyle projects, so I don’t know how this would work in some other make engine like mvn.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv3Uo5wuYOXhcpOm-mnf6tP9ON9KAUhJE%3DzzpRc761W16w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Peter Berghold

unread,
Oct 16, 2015, 3:53:38 PM10/16/15
to jenkins...@googlegroups.com

Yah... thought of that and I'm trying to avoid that.


Christopher Orr

unread,
Oct 16, 2015, 5:13:16 PM10/16/15
to jenkins...@googlegroups.com
You can do something similar with the EnvInject plugin; there's a build
step to export some properties to the environment — that would at least
avoid the necessity to `source` the script everywhere.


On 16/10/15 21:53, Peter Berghold wrote:
> Yah... thought of that and I'm trying to avoid that.
>
>
> On Fri, Oct 16, 2015, 15:14 John Mellor <John....@esentire.com
> <mailto:John....@esentire.com>> wrote:
>
> I write out a file containing the globals and then source it
> wherever required. For downstream jobs, I have to make the file an
> artifact, so it gets copied to the master node, and then use the
> Copy-To-Slave plugin to pull it over to the current node.____
>
> __ __
>
> P.S, all of my builds use various forms of freestyle projects, so I
> don’t know how this would work in some other make engine like mvn.____
>
> __ __
>
> *From:*jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>
> [mailto:jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>] *On Behalf Of *Peter Berghold
> *Sent:* October-16-15 14:57
> *To:* jenkins...@googlegroups.com
> <mailto:jenkins...@googlegroups.com>
> *Subject:* Global environmental variables____
>
> __ __
>
> Riddle me this Batman.____
>
> __ __
>
> Is there a way in Jenkins to set a global value that build jobs can
> access in a shell? ____
>
> __ __
>
> Reason I ask is I'm about to create a build job that sets up files
> for release by gathering a host of modules, staging them and then
> creating not one but two tarballs for distribution. I need to
> designate what the build tag is to help name the tarballs.____
>
> __ __
>
> modules-{TAG}-{SEMANTIC VERSION}-release.tar.gz____
>
> __ __
>
> I'd like the to set the TAG and SEMANTIC VERSION in one place and
> have it carry everywhere....____
>
> __ __
>
> --
> You received this message because you are subscribed to the Google
> Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jenkinsci-use...@googlegroups.com
> <mailto:jenkinsci-use...@googlegroups.com>.
> <https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv3Uo5wuYOXhcpOm-mnf6tP9ON9KAUhJE%3DzzpRc761W16w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.____
>
> --
> You received this message because you are subscribed to the Google
> Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jenkinsci-use...@googlegroups.com
> <mailto:jenkinsci-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/97e85cf2af374fe0b66a54ca5bd1c1f4%40mbx01colo01p.esentire.local
> <https://groups.google.com/d/msgid/jenkinsci-users/97e85cf2af374fe0b66a54ca5bd1c1f4%40mbx01colo01p.esentire.local?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to jenkinsci-use...@googlegroups.com
> <mailto:jenkinsci-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv1o7-SEiq1jDrHhMNmaP_ZhFQpYNDfy7i9RWFeLYr%3D9sg%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv1o7-SEiq1jDrHhMNmaP_ZhFQpYNDfy7i9RWFeLYr%3D9sg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Ioannis Moutsatsos

unread,
Oct 21, 2015, 7:10:40 AM10/21/15
to Jenkins Users
Have you considered the metadata plugin? You can define key value metadata and can expose them as environment variables.These definitions are done at the project configuration level and will apply to all the builds of the project.

Just a thought.
Ioannis
Reply all
Reply to author
Forward
0 new messages