<p>I am trying to setup declarative pipeline where I would like to persiste workspace as volume claim so large git checkout can be faster. Based on <a href="https://jenkins.io/doc/pipeline/steps/kubernetes/" rel="noreferrer">doc</a> there are options <code>workspaceVolume</code> and <code>persistentVolumeClaimWorkspaceVolume</code> but I am not able to make it work - jenkins always does following:</p>

<pre><code>volumeMounts:
 - mountPath: "/home/jenkins/agent"
   name: "workspace-volume"
   readOnly: false
volumes:
  - emptyDir: {}
    name: "workspace-volume"
</code></pre>

Robert Ohajda
<p>Try something like</p>

<pre><code>podTemplate(
    containers: [
        containerTemplate(name: 'tree', image: 'iankoulski/tree', ttyEnabled: true, command: 'cat')
    ], 
    workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false),
) {
    node(POD_LABEL) {
        stage('read workspace') {
            checkout scm
            container('tree') {
                sh 'env'
                sh 'tree'
                sh 'test -f old-env.txt &amp;&amp; cat old-env.txt'
                sh 'env &gt; old-env.txt'
            }
        }
    }
}
</code></pre>
