我有一个 groovy 类,我试图从文件夹级共享库中导入它。
这是 groovy 类 -
package abc.esmm
@Singleton
class JiraCommands implements Serializable
{
def steps
def jiraCommandsTool
def Initialize(steps)
{
this.steps = steps
jiraCommandsTool = "${steps.WORKSPACE}/JenkinsPipeline/UtilityScripts/bin/JiraCommands"
}
def AddFixVersionToJiraIssues(jiraIssues, fixVersion, overwriteFixVersionParam=false)
{
def overwriteFixVersion = "False"
if(overwriteFixVersionParam)
{
overwriteFixVersion = "True"
}
steps.sh(returnStdout: true, script: "${jiraCommandsTool} -command addFixVersionToJira -jiraIssues \"${jiraIssues}\" -fixVersion ${fixVersion} -overwriteFixVersion ${overwriteFixVersion}").trim()
}
}
我尝试使用此管道代码创建此类的实例:
@Library('LotteryFolderPipelineLibs')
import abc.esmm.JiraCommands
node('All_LinuxBuildPool')
{
JiraCommands.instance.Initialize(this)
}
从 Jenkins Global 共享库调用时可以正常工作,但从文件夹级共享库调用时则不行。全局共享库和文件夹级共享库指向同一个代码。从文件夹级共享库调用时,我收到此错误:
CpsCallableInvocation{methodName=getInstance,call=null,receiver=class abc.esmm.JiraCommands,arguments=[]} 完成:失败
有谁知道为什么会这样?