Issue
I am able to find the files under the checked out git repo with the following code
stage('Clone and Upload') {
steps {
git branch: params.GIT_BRANCH, credentialsId: 'my-bitbucket-id', url: params.GIT_REPO
script {
def files = findFiles excludes: '', glob: ''
files.each { f ->
if (f.directory && f.name == 'MyScripts'){
echo "Folder: $f.name" // Prints Folder: MyScripts
}
}
}
}
}
But I want to list all the files inside 'MyScripts' folder next. How do I do that?
Solution
You can do something like the following.
def files = findFiles excludes: '', glob: ''
files.each { f ->
if (f.directory && f.name == 'MyScripts'){
echo "Folder: $f.name" // Prints Folder: MyScripts
dir('MyScripts') {
sh "pwd"
def fileList = findFiles(glob: '*.*')
echo "$fileList"
}
}
}
Answered By - ycr
Answer Checked By - Mildred Charles (JavaFixing Admin)