Environmental variables

Screenshot 2022-07-21 at 12.16.38 AM

  1. Why am I not getting the global value of PATH , even after using env ? Can’t we get the global value if we define the local variable with the same name of global variable ?

  2. What is the use of $ in referencing variables as I am able to reference without the $ ?

Hi @dnpuneeth3

  1. Please see this discussion about setting PATH.
  2. $ syntax is for creating “interpolated strings” when you want to embed the value of a variable into a string constant, e.g.
    "The value of x is ${x}".
    If you just want to use the variable as-is, then it doesn’t need to be quoted or dollared. The exception to this is in the environment { } block where variable value assignments must always be quoted, so to achieve this when all you want is the value of another variable, it must be "${variable}".
1 Like

What is the use of env ? As we can reference the global variables with and without env .

Both env.BUILD_NUMBER and BUILD_NUMBER works

I think only for legibility.
Both work equally well