jenkins pod template files are not viewable from other stages

12/9/2018

I am running jenkins jobs using the kubernetes pod templates plugin.

In the first stage of the build i have some files that get created and they are using pod template A, but these files seem to not be written to the workspace for other stages to use.

For instance, the second stage using pod template B can not see the files written by template A in the first stage. Template B writes files to the workspace in stage two, and pod template C in stage third can see those files written by template B in stage two.

This leads me to believe theres an issue with the pod template, but i have completely copied all variables, volume mounts, and jnlp container to my template A and yet it still doesnt work. If i kubectl describe my pod it says all volume mounts were successful, any thoughts, or tips for debugging the volume mounts?

pipeline {
  agent {
    label "jenkins-nodejs"
  }
  stages {
    stage('first stage'){
        steps{
            container('template A'){
                sh 'echo this file wont be found > fileOne.txt'
            }
        }
    }

    stage('second stage'){
        steps{
            container('template B'){
                // No file found here
                sh 'cat fileOne.txt'
                sh 'echo this file will be found > fileTwo.txt'
            }
        }
    }

    stage('third stage'){
        steps{
            container('template C'){
                // No file found here
                sh 'cat fileOne.txt'

                // File found here
                sh 'cat fileTwo.txt'
            }
        }
    }
  }
  post {
    always {
        cleanWs()
    }
  }
}
-- BLang
jenkins
jenkins--x
kubernetes

0 Answers