[英]How to list files under a folder using jenkins
I am able to find the files under the checked out git repo with the following code我可以使用以下代码在签出的 git 存储库下找到文件
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.但接下来我想列出“MyScripts”文件夹中的所有文件。 How do I do that?我怎么做?
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"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.