Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62160

persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • kubernetes-plugin
    • None

      I have this feature working in a scripted pipeline but when I tried to use it in a declarative pipeline it would never create the workspace volume as a persistent volume claim, it would only mount "emptyDir" volumes for the workspace. 

      The declarative pipeline I'm using is

      pipeline {
       agent {
         kubernetes {
           yamlFile 'jenkins/pv-pod.yaml'
           defaultContainer 'tree'
         }
       }
       options {
         podTemplate(workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false))
       }
       stages {
         stage('read workspace') {
           steps {
             echo 'current env'
             sh 'env'
             sh '/usr/bin/tree'
             echo 'previous env'
             sh 'cat old-env.txt || true'
             sh 'env > old-env.txt'
           }
         }
       }
      }
      

       

      With a 'pv-pod.yaml' file with these contents

      apiVersion: v1
      kind: Pod
      spec:
       containers:
       - name: tree
         image: iankoulski/tree
         command:
         - /bin/cat
         tty: true
      

      This is in kubenernetes-plugin version 1.25.3.

       

            Unassigned Unassigned
            dwarburton david warburton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: