Created
September 29, 2016 23:31
-
-
Save KenDUemura/48856cc1e9cd1aedf041b602ce89bf15 to your computer and use it in GitHub Desktop.
Jenkins Pipeline, Get current Job's Folder Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getFolderName() { | |
def array = pwd().split("/") | |
return array[array.length - 2]; | |
} | |
node(){ | |
stage 'Get Folder Name' | |
def foldername = getFolderName() | |
print "${foldername}" | |
} |
Great! You can also check the env variables that Jenkins offers you https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
For example env.JOB_NAME prints folder name and job name
This is what I am looking for, thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! You can also check the env variables that Jenkins offers you
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
For example env.JOB_NAME prints folder name and job name