-
Bug
-
Resolution: Fixed
-
Minor
-
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.
- links to