Interview Prep/Jenkins/Plugins, JCasC & Jenkins on Kubernetes

What are pod template inheritance and `POD_LABEL`?

AdvancedConceptPlugins, JCasC & Jenkins on Kubernetes
Answer

Templates can inherit from others with inheritFrom 'base', merging containers, volumes and YAML (yamlMergeStrategy merge()), so a common base defines the jnlp image, node selector and tolerations. In scripted pipelines, podTemplate { node(POD_LABEL) { } } uses the automatically generated unique label for the template just defined:

podTemplate(inheritFrom: 'base', containers: [containerTemplate(name: 'go', image: 'golang:1.23', command: 'sleep', args: 'infinity')]) {
  node(POD_LABEL) { container('go') { sh 'go test ./...' } }
}
All Jenkins questions Roadmap: Jenkins

More on Plugins, JCasC & Jenkins on Kubernetes