If you have some complicated code and you don't want to store it on the Jenkins configuration page, you can extract it to a Groovy file, save this file in a folder and add this folder to the classpath. After that you will be able to import this class from your code.

Example:


    > cd /var/lib/jenkins
    > mkdir groovy_scripts
    > echo "class Constants { public static final int TIMEOUT = 10; }" > groovy_scripts/Constants.groovy
    

Now you can add the folder /var/lib/jenkins/groovy_scripts to the classpath and do something like this:


    import Constants
    log.info Constants.TIMEOUT