| While working around the changes in JENKINS-58705, I discovered the KubernetesDeclarativeAgent.workingDir attribute method of configuring the workspace-volume of the Jenkins agent is ignored as it results in the recent /home/jenkins/agent/ change. Example Jenkinsfile demonstrating issue:
pipeline {
agent {
kubernetes {
cloud 'openshift'
label UUID.randomUUID().toString()
workingDir '/home/jenkins'
}
}
options {
timestamps()
}
stages {
stage('Greeting') {
steps {
script {
container('jnlp') {
sh 'echo "Hello world"'
}
}
}
}
}
}
Resulting console output:
[Pipeline] Start of Pipeline [Pipeline] podTemplate [Pipeline] { [Pipeline] node Still waiting to schedule task ‘eb0a374c-d844-4327-a140-891e892cfd76-793rd-5rhhr’ is offline Agent eb0a374c-d844-4327-a140-891e892cfd76-793rd-5rhhr is provisioned from template Kubernetes Pod Template — apiVersion: "v1" kind: "Pod" metadata: annotations: buildUrl: "http://172.24.30.67:80/job/os-demo-afeller/job/os-demo-afeller-pull-request/18/" labels: jenkins: "slave" jenkins/eb0a374c-d844-4327-a140-891e892cfd76: "true" name: "eb0a374c-d844-4327-a140-891e892cfd76-793rd-5rhhr" spec: containers:
- env:
- name: "JENKINS_SECRET"
value: "********"
- name: "JENKINS_TUNNEL"
value: "172.24.221.21:50000"
- name: "JENKINS_AGENT_NAME"
value: "eb0a374c-d844-4327-a140-891e892cfd76-793rd-5rhhr"
- name: "JENKINS_NAME"
value: "eb0a374c-d844-4327-a140-891e892cfd76-793rd-5rhhr"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
- name: "JENKINS_URL"
value: "http://172.24.30.67:80/"
- name: "HOME"
value: "/home/jenkins" image: "jenkins/jnlp-slave:alpine" name: "jnlp" volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume" readOnly: false nodeSelector: {} restartPolicy: "Never" volumes:
- emptyDir: {}
name: "workspace-volume"
As the KubernetesDeclarativeAgent passes configuration to PodTemplate, I think the issue is in PodTemplate resolves the working dir. |