Environmental values from a Groovy Pipeline.

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

Environmental values from a Groovy Pipeline.

Peter Berghold
I am most interested in using the "WORKSPACE" value in the enviromental values. within my pipeline..  I use it as a base to create a staging directory from so I have a value defined such as:

def outrepo="${env.WORKSPACE}/shipping-${env.BUILD_NUMBER}"

what I am getting back from that is not what I'm expecting at all. 

OUTREPO: null/shipping-152

Looks like env.WORKSPACE is being resolved as a "null" instead of the full path to the job's workspace. 

Is there a different form of this I should be using?  I clearly see WORKSPACE as being defined when within a shell I see that value running the shell command "env."

I could hard code it I supposed, but that kind defeats the purpose a bit....

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv34ASTPPd6rfC5zQ%2BwXG%3Do5Q-xdwwAsriL-vwvJ6x8aeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Environmental values from a Groovy Pipeline.

Björn Pedersen
Hi,

it depends on where in your code you are trying to use this. A workspace is only available (and the  env set) while inside a node or ws block. And beware, when different parts of the pipeline run on different node, then each
part has it's own workspace, possibly even at different locations.  And unless there are strong requirements for absolute pathes,  better just use relative pathes (all steps will by default have the WORKSPACE as current working dir).

Björn

Am Donnerstag, 30. November 2017 21:48:15 UTC+1 schrieb Peter Berghold:
I am most interested in using the "WORKSPACE" value in the enviromental values. within my pipeline..  I use it as a base to create a staging directory from so I have a value defined such as:

def outrepo="${env.WORKSPACE}/shipping-${env.BUILD_NUMBER}"

what I am getting back from that is not what I'm expecting at all. 

OUTREPO: null/shipping-152

Looks like env.WORKSPACE is being resolved as a "null" instead of the full path to the job's workspace. 

Is there a different form of this I should be using?  I clearly see WORKSPACE as being defined when within a shell I see that value running the shell command "env."

I could hard code it I supposed, but that kind defeats the purpose a bit....

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ff698027-6d29-476c-b04b-ac2397561c9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Environmental values from a Groovy Pipeline.

Peter Berghold
sounds like that was what bit me.   I'm seeing bizarre behavior all over the place that now makes sense given what you said about node {} 

On Fri, Dec 1, 2017 at 1:19 AM 'Björn Pedersen' via Jenkins Users <[hidden email]> wrote:
Hi,

it depends on where in your code you are trying to use this. A workspace is only available (and the  env set) while inside a node or ws block. And beware, when different parts of the pipeline run on different node, then each
part has it's own workspace, possibly even at different locations.  And unless there are strong requirements for absolute pathes,  better just use relative pathes (all steps will by default have the WORKSPACE as current working dir).

Björn


Am Donnerstag, 30. November 2017 21:48:15 UTC+1 schrieb Peter Berghold:
I am most interested in using the "WORKSPACE" value in the enviromental values. within my pipeline..  I use it as a base to create a staging directory from so I have a value defined such as:

def outrepo="${env.WORKSPACE}/shipping-${env.BUILD_NUMBER}"

what I am getting back from that is not what I'm expecting at all. 

OUTREPO: null/shipping-152

Looks like env.WORKSPACE is being resolved as a "null" instead of the full path to the job's workspace. 

Is there a different form of this I should be using?  I clearly see WORKSPACE as being defined when within a shell I see that value running the shell command "env."

I could hard code it I supposed, but that kind defeats the purpose a bit....

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ff698027-6d29-476c-b04b-ac2397561c9e%40googlegroups.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAArvnv0-qPKcJBjJKW4u6yRvhzTP7KwS7OATcvavUT20mMLFeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.