Skip to content

Support Alpine-based containers with Agent Injection#2823

Draft
zhan9san wants to merge 1 commit intojenkinsci:masterfrom
zhan9san:feature/add-agent-image
Draft

Support Alpine-based containers with Agent Injection#2823
zhan9san wants to merge 1 commit intojenkinsci:masterfrom
zhan9san:feature/add-agent-image

Conversation

@zhan9san
Copy link
Copy Markdown

@zhan9san zhan9san commented Apr 10, 2026

fix #2822

Testing done

Add agentInjectionImage configuration for Alpine support

Adds an optional agentInjectionImage field to PodTemplate, allowing users to specify a custom agent injection image (e.g., Alpine variants) instead
of always using the default glibc-based image.

MOTIVATION
Agent injection currently always uses jenkins/inbound-agent:3355.v388858a_47b_33-3-jdk21, which is incompatible with Alpine containers (musl libc
vs glibc).

CHANGES

  • PodTemplate.java: Added agentInjectionImage field with getter/setter
  • PodTemplateBuilder.java: Image resolution priority: custom image > registry prefix > system property > default
  • PodTemplateUtils.java: Added field to template inheritance
  • config.jelly: Added UI textbox field
  • help-agentInjectionImage.html: Added documentation

TESTING
Automated: Added 3 test cases in PodTemplateBuilderTest covering custom image usage, priority override, and backward compatibility. All 17 tests
pass.

Manual: Deployed plugin, configured PodTemplate with agentInjectionImage=jenkins/inbound-agent:3355.v388858a_47b_33-3-alpine-jdk21, verified init
container uses specified image, confirmed agent connects with Alpine container.

BACKWARD COMPATIBILITY
Fully compatible - existing templates without the field use default behavior unchanged.

image

here is the generated template.

  initContainers:
  - command:
    - "sh"
    - "-c"
    - "ls -al"
    image: "busybox:1.36"
    name: "volume-mount-permission"
    securityContext:
      runAsUser: 0
  - command:
    - "/bin/sh"
    - "-c"
    - "cp $(command -v jenkins-agent) /jenkins-agent/jenkins-agent;cp -R /usr/share/jenkins/.\
      \ /jenkins-agent"
    image: "jenkins/inbound-agent:3355.v388858a_47b_33-3-alpine3.23-jdk21"
    name: "set-up-jenkins-agent"
    volumeMounts:
    - mountPath: "/jenkins-agent"
      name: "jenkins-agent"
  nodeSelector:
    kubernetes.io/os: "linux"
  restartPolicy: "Never"
  volumes:
  - emptyDir:
      medium: ""
    name: "workspace-volume"
  - emptyDir: {}
    name: "jenkins-agent"

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@zhan9san zhan9san requested a review from a team as a code owner April 10, 2026 19:49
@zhan9san zhan9san marked this pull request as draft April 11, 2026 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Alpine-based containers with Agent Injection

1 participant