The best way to download common groovy code is with shared libraries .
If you have a shared library:
simplest-jenkins-shared-library master % cat src/org/foo/Bar.groovy package org.foo; def awesomePrintingFunction() { println "hello world" }
Drag it to the original control, configure it in your jenkins work, or even globally (this is one of the only things you do through the Jenkins user interface when using the pipeline), as in this screenshot:

and then use it, for example, as follows:
pipeline { agent { label 'docker' } stages { stage('build') { steps { script { @Library('simplest-jenkins-shared-library') def bar = new org.foo.Bar() bar.awesomePrintingFunction() } } } } }
The output from the console log for this assembly, of course, will include:
hello world
There are many other ways to write shared libraries (e.g. using classes) and using them (e.g. defining vars so you can use them in Jenkinsfiles in super-slick ways). You can even upload non-groovy files as resources. Check out the shared library docs for these extended use cases.
source share