简体   繁体   English

如何使用 jenkins 列出文件夹下的文件

[英]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.

相关问题 如何使用 Java 获取 GitHub 项目文件夹下所有文件及其原始内容的列表? - How to get list of all files and their raw contents under the GitHub project folder using the Java? 如何使用 JavaScript 列出文件夹中的本地文件? - How to list local files in a folder using JavaScript? 如何在UNIX下使用(C)将文件从一个文件夹传输到另一个文件夹? - How can I transfer files from one folder to another folder using (C) under UNIX? 如何使用Cmake将通用头文件文件夹下的头子文件夹中的头文件分组 - How to group header files in header subfolders under the general header files folder using Cmake 如何以编程方式获取文件夹结构下的锁定文件列表? - How do I programmatically get a list of locked files under a folder structure? 如何在Windows操作系统中的文件夹下的文件中搜索文本 - How to search a text in the files under a folder in Windows operating system 使用文件名列表从文件夹中删除文件? - Remove files from a folder using list of a filename? 使用JSP列出文件夹中特定扩展的文件 - list files of a specific extension in a folder using JSP 在Android中如何获取sys文件夹中的文件列表 - In Android how to get the list of files in sys folder 如何在Wordpress中列出自定义文件夹中的文件? - How to List the Files from a Custom Folder in Wordpress?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM