I have a Jenkins Pipeline JOB where I declared some stages that use an external function that I created by myself in the same groovy script.
errorList = ["badGatewayMsg", "closedByRemoteHostMsg", "connectionTimedOut"]
def boolean someFunction(name) {
String jobLog = jenkins.model.Jenkins.instance.getItemByFullName(name).lastBuild.log
for (error in errorList) {
if (jobLog.contains(error))
return true
}
return false
}
stage('stage1') {
if(someFunction('job1Name'))
// do Something
}
stage('stage2') {
if(someFunction('job2Name'))
// do Something
}
When I want to start this pipeline build i get the following error:
java.lang.NoSuchMethodError: No such DSL method 'someFunction' found among steps ....
Thanks for your help!