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 ./...' } }
}
More on Plugins, JCasC & Jenkins on Kubernetes
How do you manage plugins in a reproducible way?IntermediateWhat does `jenkins-plugin-cli` resolve for you, and what flags matter?IntermediateWhy should you keep the number of plugins low?BeginnerWhat is JCasC and how is it loaded?BeginnerWhat are the top-level root elements in a JCasC file?IntermediateHow do you inject secrets into JCasC without committing them?Advanced