【发布时间】:2017-03-05 22:47:23
【问题描述】:
我们正在使用 Pipeline Shared Libraries 插件来分解我们不同 Jenkins 流水线共有的代码。
From its documentation,它为非 Groovy 文件提供了一个 resources 顶级文件夹。由于我们依赖不同的 bash 函数,我们希望将它们托管在单独的 .sh 文件中(因此它们也可以被 Jenkins 以外的其他进程使用)。
相同的文档告诉我们使用libraryResource 步骤来加载这些资源文件。我们可以在我们的 Groovy 脚本中成功调用此方法,并将我们的资源文件名作为参数 (function.sh)。但是从这里开始,我们无法找到一种方法来从同一个 Groovy 脚本调用 function.sh 中定义的 foofoo 函数。
sh "foofoo" #error: foofoo is not defined
我们也尝试先这样获取它:
sh "source function.sh && foofoo"
但它在source 步骤失败,说明找不到function.sh。
调用function.sh中定义的bash函数的正确过程是什么
【问题讨论】:
标签: bash jenkins groovy jenkins-pipeline