https://github.com/jenkinsci/docker-jnlp-slave
https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-LaunchslaveagentviaJavaWebStart
Jenkins > Manage Jenkins > Configure Global Security > Enable Security > Fixed > 输入任意未被占用端口
Jenkins > Manage Jenkins > Manage Nodes > New Node > 输入节点名(很重要,我起名“agent-2”) > Permanent Agent > 远程目录随便填写 > Save
完成上述之后,这个时候节点是红色的叉叉;你可以在节点列表点击节点名称进去查看jnpl的文件地址下载到本机运行Worker也可以利用我这个例子Docker中运行Worker.
依赖上述Docker镜像,注意节点名称必须一致,我这里新建的节点名叫“agent-2”。
docker service create --name jenkins-agent-2 --user root jenkinsci/jnlp-slave -url http://10.47.192.7:8080/ 3083d678be6893f8ecd37d02972830c61baa59d29ae831c42058a24b65150c34 agent-2
docker run -d --name jenkins-agent-3 \
--add-host "registry.nakedhub.cn:172.16.1.12" \
-e JENKINS_URL="http://139.224.47.139:8080/" \
-e JENKINS_NAME="internal" \
-e JENKINS_SECRET="e481b9d6cbcf20d5d841396b6c64cc93c22d7d00f6ef791cbc9f329761d9d961" \
--user root jenkinsci/jnlp-slave
Jenkins的Docker Publish Plugin插件有BUG,远程镜像仓库安全登录校验没效果,构建Push到远程私有镜像仓库会出现”denied: requested access to the resource is denied”,需要手动处理;有二种方式。
docker cp ~/.docker/config.json jenkins-agent-2:/home/jenkins/.docker/
Docker CLI会安装在(/var/lib/jenkins/tools/org.jenkinsci.plugins.docker.commons.tools.DockerTool/Docker-1.13.0-rc3/docker/bin)中。
./docker -H tcp://10.47.193.129:4243 login -u alittlebrain@qq.com -p 123456 registry-internal.cn-hangzhou.aliyuncs.com