I am trying to get all the directories that are under one directory(deployment) by using groovy(in Jenkins pipeline). To do this I used the following code snippet.
def currentDir = new File("${WORKSPACE}/deployment")
currentDir.eachFile FileType.DIRECTORIES, {
println it.name
}
After executing this I am only receiving one directory even though there are several directories.
I tried another code snipped which gave me the entire path of the directory. But still here also I am only getting one directory path even though there are several directories.
def dir = new File("${WORKSPACE}/deployment")
dir.eachFileRecurse (FileType.DIRECTORIES) { directory ->
println directory
}
What I actually want is the 1st solution but with all the directories. Am I doing something wrong here? Is there a setting on Jenkins pipeline to make sure that all the directories are getting visible? Please note I also allowed In Script Approval
in order to execute this.