如果
Jenkinsfile要从外部文件中获取可用的方法,则需要执行以下操作
在您的中
file1.groovy,返回对方法的引用
def firstTest() { // stuff here}def testTwo() { //more stuff here}...return [ firstTest: this.&firstTest, testTwo: this.&testTwo]EDIT
evaluatedoes not seem to be required
def externalMethod = evaluate readFile("file1.groovy")or
def externalMethod = evaluate readTrusted("file1.groovy")And as mentioned by @Olia
def externalMethod = load("file1.groovy")should work
Here is a reference on
readTrusted. 请注意,不允许使用
参数替换(进行轻量级签出)
从轻量级结帐:
如果选择此选项,请尝试直接从
SCM 获取管道脚本内容,而不执行完整的检出。这种模式的优点是
效率高。但是,您将不会获得基于
SCM的任何更改日志或轮询。(如果在构建过程中使用checkout scm,则将填充
变更日志并初始化轮询。)
在这种模式下,构建参数也不会替换为SCM配置。仅选定的SCM插件
支持此模式。
至少对我有用



