<p>The idea is to store persistently the data generated by the user in Jenkins Dashboard (jobs, scriptlers, credentials, ...) so when I mount theses volumes after each restart, I am able to retrieve the stored data  (mounted volumes) in jobs and scriptlers. (I am not using the solution with JcasC (yaml files) for jobs, scriptlers, ... as the user will define them dynamically from the UI).</p>
<p>Now, I am trying to mount the &quot;credentials.xml&quot; file (persistent volume), as I made with &quot;scriptler&quot; and &quot;jobs&quot; folder mount. But it does not work because it's a file, not a folder.</p>
<p>The solution to mount as a ConfigMap is not applicable here as the file cannot be predefined because modified by the user in the dashboard for any change in credentials.</p>
<p>I am looking for a solution to mount this file like a &quot;persistent volume&quot;</p>
<p>Here is my YAML deployment (values) file (it does not work with 'jenkins-credentials' mount):</p>
<pre><code>persistence:
  volumes:
    - name: jenkins-jobs
      persistentVolumeClaim:
        claimName: jenkins-jobs

    - name: jenkins-scriptlers
      persistentVolumeClaim:
        claimName: jenkins-scriptlers

    - name: jenkins-credentials
      configMap:
        name: cm-credentials-xml

  mounts:
    - name: jenkins-jobs
      mountPath: /var/jenkins_home/jobs
      readOnly: false

    - name: jenkins-scriptlers
      mountPath: /var/jenkins_home/scriptler
      readOnly: false

    - name: jenkins-credentials
      mountPath: /var/jenkins_home/credentials.xml
      #subPath: credentials.xml
      readOnly: false
</code></pre>
<p>Thanks</p>

Maurice Amar
<p>Since all the VolumeMounts share the same 'volume' and the directory <code>/var/jenkins_home</code> you actually need one main volume. Something like this should work. (I tested myself mounting a file and works for me) This assumes that the root of your persistent volume (<code>/</code>) has the main content.</p>
<pre class="lang-yaml prettyprint-override"><code>persistence:
  volumes:
    - name: jenkins-home
      persistentVolumeClaim:
        claimName: jenkins-home

  mounts:
    - name: jenkins-home
      mountPath: /var/jenkins_home/jobs
      subpath: jobs
      readOnly: false

    - name: jenkins-home
      mountPath: /var/jenkins_home/scriptler
      subPath: scriptler
      readOnly: false

    - name: jenkins-home
      mountPath: /var/jenkins_home/credentials.xml
      subPath: credentials.xml
      readOnly: false
</code></pre>
<p>Note: This is not K8s configuration, so I assume it's Jenkins config YAML.</p>
