The jenkins-agent ConfigMap was removed from the Helm chart in CloudBees CI 2.568.2.37664 (deprecated as of 2.462.3.3).
|
If your pod templates use the jenkins-agent ConfigMap, you must migrate the configuration to the agent-injection option provided by the Kubernetes plugin.
-
To inject the agent, use one of the following methods:
-
Select Inject Jenkins agent in agent container.
-
Add
agentInjection: trueto thepodTemplatestep. -
Specify
agentInjection truein Declarative Pipelines.
-
-
Remove volume mounting of the
jenkins-agentConfigMap and the associated command; the injection method you selected handles this automatically.
Scripted Pipeline example
The following example uses agentInjection: true in the podTemplate step.
// Build a Maven project using the standard image and Scripted syntax. // Rather than inline YAML, you could use: yaml: readTrusted('jenkins-pod.yaml') // Or, to avoid YAML: containers: [containerTemplate(name: 'maven', image: 'maven:3.6.3-jdk-8', command: 'sleep', args: 'infinity')] podTemplate( agentContainer: 'maven', agentInjection: true, yaml: ''' apiVersion: v1 kind: Pod spec: containers: - name: maven # In a real Jenkinsfile, it is recommended to pin to a specific version and use Dependabot or Renovate to bump it. image: maven:latest resources: requests: memory: "256Mi" limits: memory: "512Mi" command: - sleep args: - infinity securityContext: # maven runs as root by default, it is recommended or even mandatory in some environments (such as pod security admission "restricted") to run as a non-root user. runAsUser: 1000 ''') { retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]) { node(POD_LABEL) { // some steps... } } }
Declarative Pipeline example
The following example uses agentInjection true in a Declarative Pipeline with agentContainer to specify the container that runs the agent.
The container specified by agentContainer must have a JDK installed and available in PATH.
|
pipeline { agent { kubernetes { agentInjection true agentContainer 'maven' yaml ''' apiVersion: v1 kind: Pod spec: containers: - name: maven # In a real Jenkinsfile, it is recommended to pin to a specific version and use Dependabot or Renovate to bump it. image: maven:latest resources: requests: memory: "256Mi" limits: memory: "512Mi" command: - sleep args: - infinity securityContext: # maven runs as root by default, it is recommended or even mandatory in some environments (such as pod security admission "restricted") to run as a non-root user. runAsUser: 1000 ''' } } stages { stage('Stage 1') { steps { // Some steps } } } }