【发布时间】:2018-07-04 09:33:09
【问题描述】:
如您所知,在 Jenkins 的共享库中,可以通过以下方式加载资源(位于资源文件夹中):
libraryResource("script.sh")
现在我的用例是我想在资源下的文件夹中加载多个文件:
+ resources
+ teamA
+ script1.sh
+ script2.sh
我想在做任何事情之前加载所有这些文件: 我在共享库中做了一个方法:
new File(scriptsFolder).eachFile() { file->
writeFile([file:"${env.workspace}/${file.getName()}",text:libraryResource("$scriptsFolder/${file.getName()}")])
sh("chmod +x ${env.workspace}/${file.getName()}")
}
在哪里scriptsFolder= "teamA"
我当然会收到java.io.IOException: Is a directory
因为libraryResource必须得到一个文件路径参数。
那么,有没有办法在不知道它们的名称或编号的情况下加载所有这些文件?
【问题讨论】:
-
可能只是资源文件夹的结帐?如何 ?还有更优雅的方式吗?
标签: jenkins shared-libraries jenkins-pipeline