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

When defining an extra container in a pod template with a custom working dir, it is wrongly used as the node working dir

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • kubernetes-plugin
    • None

      The following Jenkinsfile fails

      podTemplate(containers: [
          containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat', workingDir: '/src')
      ]) {
          node (POD_LABEL) {
              stage('Run') {
                  sh 'env | sort'
                  container('busybox') {
                      sh 'env | sort'
                  }
              }
          }
      }
      

      Whereas this one works

      podTemplate(containers: [
          containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:latest'),
          containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat', workingDir: '/src')
      ]) {
          node (POD_LABEL) {
              stage('Run') {
                  sh 'env | sort'
                  container('busybox') {
                      sh 'env | sort'
                  }
              }
          }
      }
      

      The reason is

      https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java#L130
      calls
      https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java#L276

      which then uses the working dir of the first container defined in the pod, instead of using the jnlp container all the time.

          [JENKINS-61178] When defining an extra container in a pod template with a custom working dir, it is wrongly used as the node working dir

          There are no comments yet on this issue.

            vlatombe Vincent Latombe
            vlatombe Vincent Latombe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: