<p>I am configuring a master Jenkins to start slaves with kubernetes.
When a slave starts its pipeline I need him to have a maven <code>settings.xml</code> read (or copied) from the master.
With kubernetes plugin I haven't found a way for that.</p>

<p>Any suggestions, please?</p>

Nicola Ben
<p>Maybe Jenkins <a href="https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#pipeline-basic-steps" rel="nofollow noreferrer">Pipeline: Basic Steps</a> can help you out. They offer a <a href="https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-stash-code-stash-some-files-to-be-used-later-in-the-build" rel="nofollow noreferrer">stash/unstash</a> step. Meaning you stash the <code>settings.xml</code> on the master node and unstash it on your slave that runs the build. I think currently stash/unstash only support sub-directories of the current pipeline workspace, but you could work around it by copying the <code>settings.xml</code> into the current workspace before stashing. The whole thing might look something like that:</p>

<pre><code>stage('Build') {
  node('master') {
    sh 'cp /path/to/master-node-settings-xml .'
    stash includes: 'settings.xml', name: 'settingsXml'
  }

  node('slave') {
    unstash 'settingsXml'
    sh 'mv settings.xml /path/to/slave-node-settings-xml'

    # Start your build here now ..
  }
}
</code></pre>

<p>Another option would be to pre-bake the <code>settings.xml</code> into the docker image which you are using to spin up the slave in Kubernetes. Of course this would not be an optimal solution, if your <code>settings.xml</code> changes dynamically or contains any kind of sensitive data (as one should avoid putting sensitive information inside a docker image if possible). </p>
