-
Bug
-
Resolution: Unresolved
-
Minor
-
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.
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.