[JIRA] (JENKINS-62160) persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Title: Message Title
david warburton updated an issue
Jenkins / JENKINS-62160
persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Change By:
david warburton
I have this feature working in a scripted pipeline but when I tried to use it in a declarative pipeline it would never create the workspace volume as a persistent volume claim, it would only mount "emptyDir" volumes for the workspace. The declarative pipeline I'm using is{code:java}pipeline { agent { kubernetes { yamlFile 'jenkins/pv-pod.yaml' defaultContainer 'tree' } } options { podTemplate(workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false)) } stages { stage('read workspace') { steps { echo 'current env' sh 'env' sh '/usr/bin/tree' echo 'previous env' sh 'cat old-env.txt || true' sh 'env > old-env.txt' } } }}{code} With a 'pv-pod.yaml' file with these contents{code:java}apiVersion: v1kind: Podspec: containers: - name: tree image: iankoulski/tree command: - /bin/cat tty: true{code}This is in kubenernetes-plugin version 1.25.3.
Add Comment
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
[JIRA] (JENKINS-62160) persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Title: Message Title
david warburton commented on JENKINS-62160
Re: persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
This is the generated yaml (anonimized)
Agent anwhy-fklcld-fuckqof-0nfqavjvebjog-udedqcviwl-vwbxnctaf-8-f664h is provisioned from template vcres-tjkgar_msiukwa_0Dxnpfmycoprj-firsqsxnhi-fwbmghhdm_2-k4ksh-7njl0
---
apiVersion: "v1"
kind: "Pod"
metadata:
annotations:
buildUrl: "https://tv.fmoyos-pixchwrnpnvx.ush/wxoyciu/eld/PslgdnEmvukdyakmgi/tqv/ver-cjxujky-cnybig/ktm/dlobiak%675Bejoolkhhobs-kbefsuasgk-clmbrcmxy/6/"
runUrl: "job/HbypjmSytbncdpinxr/qko/vxv-pqtkmeu-eydfbq/sgw/sfmddvo%762Vvmqjvkxrqny-brfxhedxdu-ythsihpma/8/"
labels:
jenkins: "slave"
jenkins/label: "agawg-nacfrw_dkwnknh_4Qpwsnvjwaeuf-auyqsweurs-xiegsouti_5-x4cwt"
name: "mpaid-qguadg-nqxbyop-4cqwjivsgtfxq-twmrcsovdn-vhbojcfom-4-f581d"
spec:
containers:
- command:
- "/bin/cat"
image: "iankoulski/tree"
name: "tree"
tty: true
volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
- env:
- name: "JENKINS_SECRET"
value: ""
- name: "JENKINS_TUNNEL"
value: "02.147.7.56:1864"
- name: "JENKINS_AGENT_NAME"
value: "tgrmu-bgqrng-kkyqlcy-8hnyafxtetumr-shfdkhyxbo-cnjpbanyw-4-p847s"
- name: "JENKINS_NAME"
value: "utgyv-jbsnfr-blwxojh-4hthpvnmkqatm-iipmqvfxtx-ogetrxvlx-4-p847s"
- name: "JENKINS_AGENT_WORKDIR"
value: "/home/jenkins/agent"
- name: "JENKINS_URL"
value: "https://xy.kecynt-ytjugchsvagx.com/jenkins/"
image: "jenkins/jnlp-slave:4.0.1-1"
name: "jnlp"
resources:
requests:
cpu: "100m"
memory: "256Mi"
volumeMounts:
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false
nodeSelector:
beta.kubernetes.io/os: "linux"
restartPolicy: "Never"
securityContext: {}
volumes:
- emptyDir:
medium: ""
name: "workspace-volume"
Add Comment
[JIRA] (JENKINS-62160) persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Title: Message Title david warburton commented on JENKINS-62160 Re: persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines There are additional posts about this issue here: https://stackoverflow.com/questions/57793663/how-to-define-workspace-volume-for-jenkins-pipeline-declarative and here https://groups.google.com/forum/#!topic/jenkinsci-users/DDo1Jf-GjiM Add Comment This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38) -- You received this message because you are subscribed to the Google Groups "Jenkins Issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.206083.1588626613000.21334.1588626720132%40Atlassian.JIRA.
[JIRA] (JENKINS-62160) persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Title: Message Title
david warburton created an issue
Jenkins / JENKINS-62160
persistentVolumeClaimWorkspaceVolume produces emptyDir volume instead of PVC volume when used in Declarative pipelines
Issue Type:
Bug
Assignee:
Unassigned
Components:
kubernetes-plugin
Created:
2020-05-04 21:10
Priority:
Minor
Reporter:
david warburton
I have this feature working in a scripted pipeline but when I tried to use it in a declarative pipeline it would never create the workspace volume as a persistent volume claim, it would only mount "emptyDir" volumes for the workspace. The declarative pipeline I'm using is
pipeline {
agent {
kubernetes {
yamlFile 'jenkins/pv-pod.yaml'
defaultContainer 'tree'
}
}
options {
podTemplate(workspaceVolume: persistentVolumeClaimWorkspaceVolume(claimName: 'workspace', readOnly: false))
}
stages {
stage('read workspace') {
steps {
echo 'current env'
sh 'env'
sh '/usr/bin/tree'
echo 'previous env'
sh 'cat old-env.txt || true'
sh 'env > old-env.txt'
}
}
}
}
With a 'pv-pod.yaml' file with these contents
apiVersion: v1
kind: Pod
spec:
containers:
- name: tree
image: iankoulski/tree
command:
- /bin/cat
tty: true
This is in kubenernetes-plugin version 1.25.3.
