Jenkinsfile使用Findfiles获取子目录的内容

发布于 2025-02-11 18:28:15 字数 808 浏览 1 评论 0 原文

我正在尝试使用Findfiles列出子目录的内容,但是我遇到了一些问题,

如何获取子目录的内容 尝试过

def files = findFiles(glob: "dirname/**")

,但这永远不会

尝试

dir("dirname") {
    def files = findFiles()
}

失败,因为它需要在父级目录上进行写入权限,因为它试图创建dirname@tmp。如果我在父目录上放松权限,它可以工作,但是我真的很想避免在该父目录上写入权限的詹金斯,

我也试图通过在脚本控制台中测试Findfiles如何工作

def files = findFiles() 
println(files)

,我会得到

groovy.lang.MissingMethodException: No signature of method: Script1.findFiles() is applicable for argument types: () values: [] Possible solutions: findAll(), findAll(groovy.lang.Closure), find() 

已安装,Findfiles在我的构建工作中起作用

I'm trying to use findFiles to list the contents of a sub-directory, but I'm running into some issues

How can I get the contents of a subdirectory
tried

def files = findFiles(glob: "dirname/**")

but that never ends

tried

dir("dirname") {
    def files = findFiles()
}

this fails because it needs write permission on the parent directory as it tries to create dirname@tmp . It works if I relax permissions on the parent directory, but I'd really like to avoid jenkins having write permissions on that parent directory

I'm also trying to see how findFiles works by testing it in the Script console

def files = findFiles() 
println(files)

there I get

groovy.lang.MissingMethodException: No signature of method: Script1.findFiles() is applicable for argument types: () values: [] Possible solutions: findAll(), findAll(groovy.lang.Closure), find() 

https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/ is installed, the findFiles works inside my build job

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩饰不了的爱 2025-02-18 18:28:15

您可以尝试以下操作吗?

dir('YOUR_DIR') {
  def fileList = findFiles(glob: '*.*')
  echo "$fileList"
} 

Can you try the following.

dir('YOUR_DIR') {
  def fileList = findFiles(glob: '*.*')
  echo "$fileList"
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文