[JIRA] (JENKINS-59160) Cannot Override workingDir for jnlp container

5 views
Skip to first unread message

mike_nau@intuit.com (JIRA)

unread,
Aug 30, 2019, 6:37:02 PM8/30/19
to jenkinsc...@googlegroups.com
Mike Nau created an issue
 
Jenkins / Bug JENKINS-59160
Cannot Override workingDir for jnlp container
Issue Type: Bug Bug
Assignee: Unassigned
Components: kubernetes-plugin
Created: 2019-08-30 22:36
Environment: Jenkins: 2.176.2
Jenkins Kubernetes Plugin: 1.18.3
Kubernetes: v1.13.9
Cluster OS: Amazon Linux, 64-Bit
Priority: Minor Minor
Reporter: Mike Nau

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. 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

mike_nau@intuit.com (JIRA)

unread,
Aug 30, 2019, 6:38:02 PM8/30/19
to jenkinsc...@googlegroups.com
Mike Nau updated an issue
Change By: Mike Nau
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:

 
{code:java}

    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
"""
        }
    }
{code}

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


 

 
{code:java}

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
{code}

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. 

Pierson_Yieh@intuit.com (JIRA)

unread,
Oct 16, 2019, 4:42:02 PM10/16/19
to jenkinsc...@googlegroups.com
Pierson Yieh commented on Bug JENKINS-59160
 
Re: Cannot Override workingDir for jnlp container

We also noticed that `workingDir` was only being ignored when being declared from a podTemplate / pipeline from a Jenkinsfile. Setting the working directory from pod templates saved on the Jenkins Master configuration page were being respected.

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages