K8S自构建Jenkins-Agent-JDK17镜像固定工作节点
jenkins-agent镜像制作
JDK17版本,所需安装包
链接:https://pan.baidu.com/s/1WlosABP9z_vDc2IpUs4fMg?pwd=yg24
提取码:yg24
--来自百度网盘超级会员V2的分享
Dockerfile
官网的
FROM debian:10
ARG AGENT_WORKDIR=/home/jenkins/agent
ARG VERSION=3107.v665000b_51092
ENV TZ=Etc/UTC
ENV LANG=C.UTF-8
USER root
# 配置下载源
RUN rm -rf /etc/apt/sources.list
COPY ./sources.list /etc/apt/sources.list
# 下载依赖
RUN mkdir -p /home/jenkins/agent && apt-get update && apt-get --yes --no-install-recommends install curl fontconfig git git-lfs less netbase openssh-client patch && apt-get clean && rm -rf /tmp/* /var/cache/* /usr/share/doc/* /usr/share/man/*
# 安装agent.jar slave.jar
ADD https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/3107.v665000b_51092/remoting-3107.v665000b_51092.jar /usr/share/jenkins/agent.jar
RUN chmod 0644 /usr/share/jenkins/agent.jar && ln -sf /usr/share/jenkins/agent.jar /usr/share/jenkins/slave.jar
# 配置JDK17
ENV JAVA_HOME=/opt/java/openjdk
COPY ./openjdk /opt/java/openjdk
# 设置环境变量
ENV PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN mkdir /home/jenkins/.jenkins && mkdir -p "${AGENT_WORKDIR}"
VOLUME [/home/jenkins/.jenkins]
VOLUME [/home/jenkins/agent]
WORKDIR /home/jenkins
# 配置启动脚本
COPY ./jenkins-agent /usr/local/bin/jenkins-agent
RUN chmod +x /usr/local/bin/jenkins-agent && ln -s /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-slave
# 安装 buildkit
ADD ./buildkit-v0.11.5.linux-amd64.tar.gz /usr/local/
ENTRYPOINT ["/usr/local/bin/jenkins-agent"]
jenkins-agent
官方网址
https://github.com/jenkinsci/docker-inbound-agent/blob/master/jenkins-agent
#!/usr/bin/env sh
# The MIT License
#
# Copyright (c) 2015-2020, CloudBees, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons t