// vars/buildPlugin.groovy def call(body) { // evaluate the body block, and collect configuration into the object def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config body() // now build, based on the configuration provided node { git url: "https://github.com/jenkinsci/${config.name}-plugin.git" sh "mvn install" mail to: "...", subject: "${config.name} plugin build", body: "..." } } // Script // buildPlugin { name = 'git' } // Declarative not yet implemented // @Grab('org.apache.commons:commons-math3:3.4.1') import org.apache.commons.math3.primes.Primes void parallelize(int count) {  if (!Primes.isPrime(count)) { error "${count} was not prime"  }  //  … } It is possible to use third-party Java libraries, typically found in Maven Central, from  trusted library code using the  @Grab  annotation. Refer to the Grape documentation for details, but simply put: Third-party libraries are cached by default in  ~/.groovy/grapes/  on the Jenkins master. External libraries may load adjunct files from a  resources/  directory using the  libraryResource  step. The argument is a relative pathname, akin to Java resource loading: Assuming the script has either been loaded as a Global Shared Library or as a Folder-level Shared Library the resulting  Jenkinsfile  will be dramatically simpler: Using third-party libraries Loading resources 71