jenkinsgroovyclassloader

Missing Jenkins functions inside loaded groovy class


I am loading external groovy class file using evaluate

readTrusted("class_file.groovy")

everything is working fine untill I am running jenkins pipeline functions like dir() or checkout() then I am getting.

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: 
No signature of method: 
GitOps.checkout() is applicable for argument types: (java.util.LinkedHashMap) 
values: [[$class:GitSCM, branches:[[name:master]], extensions:[[$class:LocalBranch], ...], ...]]

I tried different methods of loading class file nothing worked.


Solution

  • ok so my friend found an answer in https://www.jenkins.io/doc/book/pipeline/shared-libraries/#accessing-steps at the constructor level we needed to add a reference using this to the pipeline script and refer the plugin variables using that reference