将全局函数复制到jenkins中的映射

将全局函数复制到jenkins中的映射,jenkins,jenkins-plugins,Jenkins,Jenkins Plugins,假设我有一个这样的Jenkins文件: #!groovy import ... import ... import ... library identifier: 'A@master', retriever: modernSCM( [$class: 'GitSCMSource', remote: '<the github link for A>']) // ADD LIBRARY 'A' METHODS TO MAP HERE library identifi

假设我有一个这样的Jenkins文件:

#!groovy
import ...
import ...
import ...

library identifier: 'A@master', retriever: modernSCM(
  [$class: 'GitSCMSource',
   remote: '<the github link for A>'])

// ADD LIBRARY 'A' METHODS TO MAP HERE    

library identifier: 'B@master', retriever: modernSCM(
  [$class: 'GitSCMSource',
   remote: '<the github link for B>'])

// ADD LIBRARY 'B' METHODS TO MAP HERE

// rest of the jenkinsfile
这可能是一个插件还是一段简短的代码?我的目标是能够运行两个版本的
foo
,而不重写其中一个版本


编辑:为了清楚起见,函数
foo、bar、baz、quz、abc
都在两个库的
vars/
文件夹中。

您不能将
库调用的结果分配给变量吗?例如,
libA=library iden…
等?您可以,但这对
vars
文件夹中的函数没有帮助,因为它们基本上是全局单例。
global_map['A'].foo {
    asd = 'asd'
    qwe = 'qwe'
}

global_map['B'].foo {
    asd = 'asd'
    qwe = 'qwe'
}