将groovy文件加载到jenkins中并像调用共享库文件一样调用文件

问题描述 投票:0回答:1
我有多个 groovy 文件,它们被编写为库文件,并且一个文件使用文件名在另一个文件中调用。 为了避免 git 依赖,我们尝试从本地存储库加载管道共享库。 我想将所有 groovy 文件加载到 jenkins 运行时并使用文件名调用它。 有人可以帮我解决这个问题吗?

jenkins groovy jenkins-pipeline jenkins-groovy
1个回答
0
投票
您可以使用管道函数中的“加载”

https://www.jenkins.io/doc/pipeline/steps/workflow-cps/

pipeline = load 'pipeline.groovy' pipeline.functionA()
其中 pipeline.groovy

def functionA() { println("hi") } return this;
如何动态地做到这一点?我认为如果不重写 CpsGroovyShellFactory 的大量代码就不可能做到这一点

© www.soinside.com 2019 - 2024. All rights reserved.