If your Jenkinsfile
and groovy file in one repository and Jenkinsfile
is loaded from SCM you have to do:
Example.Groovy
def exampleMethod() {
//do something
}
def otherExampleMethod() {
//do something else
}
return this
JenkinsFile
node {
def rootDir = pwd()
def exampleModule = load "${rootDir}@script/Example.Groovy "
exampleModule.exampleMethod()
exampleModule.otherExampleMethod()
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…