[JIRA] (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

8 views
Skip to first unread message

vincent@latombe.net (JIRA)

unread,
Feb 21, 2020, 7:55:03 AM2/21/20
to jenkinsc...@googlegroups.com
Vincent Latombe assigned an issue to Vincent Latombe
 
Jenkins / Bug 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
Change By: Vincent Latombe
Assignee: Vincent Latombe
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

vincent@latombe.net (JIRA)

unread,
Feb 21, 2020, 7:55:03 AM2/21/20
to jenkinsc...@googlegroups.com
Vincent Latombe created an issue
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2020-02-21 12:54
Priority: Minor Minor
Reporter: Vincent Latombe

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.

vincent@latombe.net (JIRA)

unread,
Feb 21, 2020, 7:56:03 AM2/21/20
to jenkinsc...@googlegroups.com
Vincent Latombe started work on Bug JENKINS-61178
 
Change By: Vincent Latombe
Status: Open In Progress

vincent@latombe.net (JIRA)

unread,
Feb 21, 2020, 8:32:03 AM2/21/20
to jenkinsc...@googlegroups.com

vincent@latombe.net (JIRA)

unread,
Feb 26, 2020, 8:57:02 AM2/26/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages