title: PersistentVolumeClaim workspace for jenkins slave
body: <p>I'm trying to keep my workspace in <code>PersistentVolumeClaim</code> by using <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow noreferrer">kubernetes-plugin</a></p>
  <p>I've created <code>PV</code> and <code>PVC</code> and I've stored my files on local disk. This pipeline has worked fine before but now workspace's are not created anymore on local disk.</p>
  <p>Here is my pipeline. Any Idea why don't work?</p>
  <pre><code>def podTemplate = &quot;&quot;&quot;
  apiVersion: v1
  kind: Pod
  spec:
    containers:
    - name: maven
      image: maven
      command:
      - sleep
      args:
      - infinity
      volumeMounts:
        - name: workspace-volume
          mountPath: /home/jenkins/agent
      workingDir: &quot;/home/jenkins/agent&quot;
    volumes:
        - name: &quot;workspace-volume&quot;
          persistentVolumeClaim:
            claimName: &quot;jenkins-slave-pvc&quot;
            readOnly: false
  &quot;&quot;&quot;
  
  
  pipeline {
      agent none
      stages {
          stage ('maven') {
              agent { 
                  kubernetes {
                      yaml podTemplate 
                      defaultContainer 'maven' 
                  } 
              }
              stages {
                  stage('Nested 1') {                  
                      steps {
                          sh &quot;touch Nested1 &amp;&amp; mvn -version&quot;
                      }
                  }
                  stage('Nested 2') {                  
                      steps {
                          sh &quot;mvn -version 2 &amp;&amp; touch Nested2 &quot;
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Now Jenkins always mount the volume like this:</p>
  <pre><code>volumeMounts:
   - mountPath: &quot;/home/jenkins/agent&quot;
     name: &quot;workspace-volume&quot;
     readOnly: false
  volumes:
    - emptyDir:
        medium: &quot;&quot;
      name: &quot;workspace-volume&quot;
  </code></pre>
  <p><strong>My question is:</strong> How can I overwrite the default value of <code>emptyDir</code> with my <code>persistentVolumeClaim</code> to be my workspace-volume?</p>