Custom Jenkins Agent¶
If you need to use a Jenkins Agent with a specific environment, such as a special version of JDK or specific tools, you can achieve this by creating a custom Jenkins Agent. This document describes how to customize a Jenkins Agent in DCE 5.0. The added Agent will be global, meaning all pipelines can use this Agent.
Configure Jenkins¶
- Navigate to Container Management -> Clusters , select the cluster and namespace where Jenkins is installed (the default cluster name is kpanda-global-cluster, and the namespace is amamba-system).
- Select ConfigMaps and Secrets -> ConfigMaps, choose the namespace where Jenkins is installed, and search for
jenkins-casc-config
. -
Select Edit YAML , search for
jenkins.clouds.kubernetes.templates
, and add the following content (using the addition of maven-jdk11 as an example):- name: "maven-jdk11" # (1)! label: "maven-jdk11" # (2)! inheritFrom: "maven" # (3)! containers: - name: "maven" # (4)! image: "my-maven-image" # (5)!
- Name of the custom Jenkins Agent
- Label for the custom Jenkins Agent. To specify multiple labels, separate them with spaces.
- Name of the existing pod template that this custom Jenkins Agent inherits from.
- Name of the container specified in the existing pod template that this custom Jenkins Agent inherits from.
- Use the custom image.
Note
You can also add other ConfigMaps related to podTemplate in the containers section. Jenkins uses YAML merge, so fields that are not filled in will inherit from the parent template.
-
Save the ConfigMaps. Wait for about a minute, and Jenkins will automatically reload the profile.
Usage¶
-
Orchestrate the pipeline through the DAG page
On the DAG orchestration page, click Global Settings, choose node as the type, and select your custom label.
-
Orchestrate the pipeline through JenkinsFile
Reference the custom label in the agent section of the JenkinsFile: