环境:
例子:XuXiaoCong-Windows.bat
java -jar agent.jar -jnlpUrl http://192.168.0.1:8080/computer/XuXiaoCong-Windows/jenkins-agent.jnlp -secret 1234567890abcdefg -workDir "F:\Jenkins_nodes\XuXiaoCong-Windows"
FROM alpine WORKDIR /jenkins # apk镜像 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories # 添加curl,git,openjdk11 RUN apk add --no-cache curl RUN apk add --no-cache git RUN apk add --no-cache openjdk11 # 添加其他运行环境(这里以Python为例) RUN apk add --no-cache build-base RUN apk add --no-cache python3 RUN apk add --no-cache python3-dev RUN apk add --no-cache py3-pip # Jenkins页面上的agen.jar路径(右键复制链接) RUN curl -o agent.jar http://192.168.0.1:8080/jnlpJars/agent.jar # 执行该节点(语句从Jenkins节点界面上复制)(只执行一条CMD,其余注释) # XuXiaoCong-Linux节点 CMD java -jar agent.jar -jnlpUrl http://192.168.0.1:8080/computer/XuXiaoCong-Linux/jenkins-agent.jnlp -secret 1234567890abcdefg -workDir "/var/jenkins" # docker build -t jenkins-node-xuxiaocong-linux . # docker run -d --restart=always --name=jenkins-node-xuxiaocong-linux jenkins-node-xuxiaocong-linux # XuXiaoCong-Linux-1节点 # CMD java -jar agent.jar -jnlpUrl http://192.168.0.1:8080/computer/XuXiaoCong-Linux-1/jenkins-agent.jnlp -secret 1234567890abcdefg -workDir "/var/jenkins" # docker build -t jenkins-node-xuxiaocong-linux-1 . # docker run -d --restart=always --name=jenkins-node-xuxiaocong-linux-1 jenkins-node-xuxiaocong-linux-1
cd <文件所在路径> docker build -t jenkins-node-<节点名称> .
docker run -d --restart=always --name=jenkins-node-<节点名称> jenkins-node-<节点名称>
参考文档:
https://docs.docker.com/get-started
https://wiki.alpinelinux.org/wiki/Main_Page
https://www.cnblogs.com/jackadam/p/9290366.html