您只能使用内置步骤获得内容
libraryResource。这就是为什么在共享库中具有以下功能将其复制到临时目录并返回文件路径的原因:
@NonCPSString createTempLocation(String path) { String tmpDir = pwd tmp: true return tmpDir + File.separator + new File(path).getName()}String copyGlobalLibraryscript(String srcPath, String destPath = null) { destPath = destPath ?: createTempLocation(srcPath) writeFile file: destPath, text: libraryResource(srcPath) echo "copyGlobalLibraryscript: copied ${srcPath} to ${destPath}" return destPath}当它返回临时文件的路径时,您可以将其传递到需要文件名的任何步骤:
sh(copyGlobalLibraryscript('test.sh'))用于驻留在
resources/test.sh共享库中的文件。



