Summary
When a Kubernetes pod template has Supplemental Groups configured in the Jenkins UI/CasC (alongside Run As User / Run As Group) and also defines raw pod YAML with Yaml merge strategy = Override, the live agent pod receives runAsUser/runAsGroup but not supplementalGroups.
Same class of bug as #2444 (pod-level securityContext fields not fully merged), but specifically affects supplementalGroups from pod template fields.
Environment
- Jenkins LTS 2.555.3 (
jenkins/jenkins:lts-jdk21)
- kubernetes-plugin (current master)
- kind cluster, pod template with raw YAML + Override strategy
Steps to reproduce
- Configure a Kubernetes cloud pod template with:
- Supplemental Groups:
5001,5002
- Run As User ID:
1000
- Run As Group ID:
1000
- Yaml merge strategy: Override
- Show raw yaml in console: enabled
- Raw YAML defining at least the
jnlp container
- Run a pipeline with
agent { kubernetes { label '<template-label>' } }
- Inspect Jenkins console raw YAML and the scheduled agent pod:
kubectl get pod <agent> -o jsonpath='{.spec.securityContext}'
Expected
{
"runAsUser": 1000,
"runAsGroup": 1000,
"supplementalGroups": [5001, 5002]
}
Actual
{
"runAsUser": 1000,
"runAsGroup": 1000
}
Root cause
PodTemplateBuilder.build() applies supplementalGroups to the builder pod spec, then merges with raw YAML via PodTemplateUtils.combine(yamlPod, builderSpec). Pod-level combine() only merges runAsUser and runAsGroup.
Related
Summary
When a Kubernetes pod template has Supplemental Groups configured in the Jenkins UI/CasC (alongside Run As User / Run As Group) and also defines raw pod YAML with Yaml merge strategy = Override, the live agent pod receives
runAsUser/runAsGroupbut notsupplementalGroups.Same class of bug as #2444 (pod-level
securityContextfields not fully merged), but specifically affectssupplementalGroupsfrom pod template fields.Environment
jenkins/jenkins:lts-jdk21)Steps to reproduce
5001,500210001000jnlpcontaineragent { kubernetes { label '<template-label>' } }kubectl get pod <agent> -o jsonpath='{.spec.securityContext}'Expected
{ "runAsUser": 1000, "runAsGroup": 1000, "supplementalGroups": [5001, 5002] }Actual
{ "runAsUser": 1000, "runAsGroup": 1000 }Root cause
PodTemplateBuilder.build()applies supplementalGroups to the builder pod spec, then merges with raw YAML viaPodTemplateUtils.combine(yamlPod, builderSpec). Pod-levelcombine()only mergesrunAsUserandrunAsGroup.Related