scripted volumes are not mounted into yaml defined pods

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      When using a combination of yaml pod definition plus regular script volumes the volumes are not automatically mounted into the pod:

       

      def label = "minion-backend-${UUID.randomUUID().toString()}"
      podTemplate(
          label: label, yaml: """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: maven
          image: maven:3.5.3-jdk-8
          securityContext:
            runAsUser: 10000
          command:
          - cat
          tty: true
          env:
          - name: MAVEN_CONFIG
            value: /home/jenkins/.m2
          - name: MAVEN_OPTS
            value: '-Xmx2048m -Duser.home=/home/jenkins'
      """
      ,
          volumes: [
            secretVolume(secretName: 'maven-secret', mountPath: '/home/jenkins/.m2'),
            persistentVolumeClaim(claimName: 'maven-repo', mountPath: '/home/jenkins/.m2repo')
          ],
          imagePullSecrets: ['regcred']
        ) {
          node(label) {
              stage('Checkout source') {
                  }
              }
      }
      

      In order to mount the scripted volumes we need to add the following section to the yaml spec:

          volumeMounts:
          - mountPath: /home/jenkins/.m2
            name: volume-0
          - mountPath: /home/jenkins/.m2repo
            name: volume-1
      

            Assignee:
            Unassigned
            Reporter:
            Thorsten Kunz
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: