When we build Jenkins, the official jenkins-agent does not have the tools we use, such as helm, kubectl, curl, argocd, etc., so we need to integrate them.

Note that the official image names have changed: jenkins/agent image, originally named jenkins/slave, renamed to jenkins/agent from 4.3-2 jenkins/inbound-agent image: originally named jenkins/jnlp-slave, renamed to jenkins/inbound-agent from 4.3-2

Dockerfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FROM jenkins/inbound-agent:4.11-1-alpine-jdk11

USER root

ADD docker/docker /usr/bin/docker
ADD kubectl /usr/bin/kubectl
ADD helm /usr/bin/helm

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN chmod +x /usr/bin/docker /usr/bin/kubectl /usr/bin/helm RUN apk add curl ENTRYPOINT ["/usr/local/bin/jenkins-agent"] 

Build

1
docker build -t harbor.test.com/tools/jnlp-docker:4.11-1-alpine-jdk11 -f Dockerfile . ```