package org.jenkinsci.plugins.workflow.cps.global;

import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyShell;
import hudson.Extension;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.cps.GroovyShellDecorator;

import javax.inject.Inject;
import java.net.MalformedURLException;

/**
 * Adds the global shared library space into {@link GroovyClassLoader} classpath.
 *
 * @author Kohsuke Kawaguchi
 */
@Extension
public class GroovyShellDecoratorImpl extends GroovyShellDecorator {
    @Inject
    WorkflowLibRepository repo;

    @Override
    public void configureShell(CpsFlowExecution context, GroovyShell shell) {
        try {
            shell.getClassLoader().addURL(repo.workspace.toURL());
        } catch (MalformedURLException e) {
            throw new AssertionError(e);
        }
    }
}

@@ -293,16 +293,37 @@
 Inject;%0A
+import java.io.File;%0A
 import j
@@ -749,16 +749,25 @@
 .addURL(
+new File(
 repo.wor
@@ -772,16 +772,23 @@
 orkspace
+,%22src%22)
 .toURL()

Use a sub-directory so that in the future we can have other directories for jar files, custom functions, etc.