How to load another groovy script in the same Jenkins node? : <p>When loading a pipeline script from another pipeline script, the two pipelines don't get executed on the same node : the first one is executed on my master node and the second gets executed on a slave node.</p>

<p>I'm using Jenkins pipelines with <code>Pipeline Script from SCM</code> option for a lot of jobs in this way :</p>

<ul>
<li><p>Each of my jobs defines their corresponding Git repo URL with <code>Poll SCM</code> option so that the repository gets automatically polled when a change is made to my code (basic job usage).</p></li>
<li><p>Each of my jobs define a simple <code>Jenkinsfile</code> at the root of their repository, and the pipeline script inside does basically nothing but loading a more generic pipeline.</p></li>
</ul>

<p><em>E.g.</em> :</p>

<pre><code>node {
    // --- Load the generic pipeline ---
    checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://github/owner/pipeline-repo.git']]]
    load 'common-pipeline.groovy'
}()
</code></pre>

<p>My <em>common-pipeline.groovy</em> pipeline does the actual stuff such as building, releasing or deploying artifacts, e.g. :</p>

<pre><code>{ -&gt;
    node() {
        def functions = load 'common/functions.groovy'

        functions.build()
        functions.release()
        functions.deploy()
    }
}
</code></pre>

<p>Now I <strong>don't want to force the node for each job</strong> so both pipelines have <code>node("master")</code> or <code>node("remote")</code> because I really don't want to be handling that manually, however I'd like that once the first pipeline runs on a specific node (either <em>master</em>, <em>slave1</em>, <em>slave2</em>, <em>slave3</em>) the second/loaded pipeline gets executed on the same node, because otherwise my actual Git repository code is not available from other node's workspace...</p>

<p>Is there any way I can specify that I want my second pipeline to be executed on the same node as the first, or maybe pass an argument when using the <code>load</code> step ?</p>
