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

Cannot Override workingDir for jnlp container

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • Jenkins: 2.176.2
      Jenkins Kubernetes Plugin: 1.18.3
      Kubernetes: v1.13.9
      Cluster OS: Amazon Linux, 64-Bit

      With version 1.18.3 of the Jenkins Kubernetes Plugin, I am not able to override the default workingDir for the jnlp container. Here's the pod template I am using: 

          agent {
              kubernetes {
                  // Using a dynamic pod n ame because static labels are known to cause pod creation errors.
                  label "mypod-${UUID.randomUUID().toString()}"
                  defaultContainer "maven"
                  yaml """
      apiVersion: v1
      kind: Pod
      spec:
        containers:
        - name: jnlp
          image: jenkins/jnlp-slave:alpine
          args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
          workingDir: /home/jenkins/agent2
        - name: maven
          image: maven:3.5.3-jdk-8
          command:
          - cat
          tty: true
          workingDir: /home/jenkins/agent2
      """
              }
          }
      

      Job errors as (I have added -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true) 

      sh: 1: cd: can't cd to /home/jenkins/agent/workspace/Pipeline_With_WorkingDir
      sh: 1: cannot create /home/jenkins/agent/workspace/Pipeline_With_WorkingDir@tmp/durable-cf37f355/jenkins-log.txt: Directory nonexistent
      sh: 1: cannot create /home/jenkins/agent/workspace/Pipeline_With_WorkingDir@tmp/durable-cf37f355/jenkins-result.txt.tmp: Directory nonexistent
      mv: cannot stat '/home/jenkins/agent/workspace/Pipeline_With_WorkingDir@tmp/durable-cf37f355/jenkins-result.txt.tmp': No such file or directory
      process apparently never started in /home/jenkins/agent/workspace/Pipeline_With_WorkingDir@tmp/durable-cf37f355
      

      It appears that the workingDir on our declared jnlp container is not being respected. If I set workingDir to /home/jenkins/agent everything works as expected.  

      We have a large number of existing jobs that depend on the workingDir being set to /home/jenkins. The change to default it to /home/jenkins/agent in v1.18.0 (https://github.com/jenkinsci/kubernetes-plugin/releases/tag/kubernetes-1.18.0) caused a lot of our jobs to start failing due to them unfortunately having references to /home/jenkins spread throughout their build & test logic. We are attempting to force the default workingDir back to /home/jenkins until we can update all our existing references to it. 

            Unassigned Unassigned
            mikenau_intuit Mike Nau
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: