0

Is the Folder Name available as an environment variable similar to JOB_NAME?

For a folder; JOB_NAME contains the full path including parent folders. I want the immediate parent folder as an environment variable.

GlennH
  • 105
  • 1
  • 3
  • 11

3 Answers3

1

I used:

FOLDER_NAME=${JOB_NAME%/*}
STAGE=${JOB_NAME##*/}

See http://www.tldp.org/LDP/abs/html/parameter-substitution.html

0

No such variable exists, but $(basename $(dirname $JOB_NAME)) would give you what you are asking for.

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
0

Using the suggestion of $(basename $(dirname $JOB_NAME)) combined with the Environment Script Plugin, you should be able to set such an environment variable by selecting Generate environment variables from script and then providing the Script Content of:

echo FOLDER_NAME=$(basename $(dirname $JOB_NAME))
BrianV
  • 961
  • 8
  • 9