jenkins 添加docker容器节点

   启动命令 docker run -itd --name agent-alpine -v /data/app/jenkins:/data/app/jenkins 95601494dd21 /bin/sh

    注 : Dockerfile run.sh hosts 同级目录   hosts是拷贝的/etc/hosts文件

  Dockerfile

  run.sh

  jenkins-agent-nodejs.sh  如下

    

    

FROM hexiaoqiang/alpine:3.9

LABEL MAINTAINER="hexiaoqiang"

COPY run.sh /
COPY hosts /

RUN jar="https://jenkins.linge.io/jnlpJars/agent.jar" && \
    apk update && \
    apk upgrade && \
    apk add "openjdk8~=8.222" && \
    apk add vim && \
    addgroup -g 1000 jenkins && \
    chmod 755 /run.sh && \
    cat hosts >> /etc/hosts && \
    curl -LO $jar -k && \
    adduser -u 1000 -G jenkins -D jenkins

VOLUME ["/tmp"]
ENTRYPOINT [
"/bin/sh","/run.sh"]
#!/bin/sh

echo "192.168.52.11 jenkins.linge.io" >> /etc/hosts
/data/app/jenkins/run/jenkins-agent-alpine.sh
#if [ -z $@ ];then
#使用的过程中修改下面一行 主机地址的解析过程
#    echo "192.168.52.11 jenkins.linge.io" >> /etc/hosts
#    /data/app/jenkins/run/jenkins-agent-nodejs.sh
#else
#    $@
#fi
#!/bin/sh
if [ -z "$@" ]
then
        # 自己使用的时候 修改下面name名称为节点名称 secret为Jenkins控制台生成的代码参数
    name="nodejs"
    dir="/data/app/jenkins/home"
    jar="$(dirname $dir)/run"
    url="https://jenkins.linge.io/computer/$name/slave-agent.jnlp"
    secret="768d17d5811c7c2c474990b9fbd4f08553e260afabbf10128f3e214630e8b310"

    java -jar $jar/agent.jar -jnlpUrl $url -secret $secret -workDir $dir -noCertificateCheck
else
    $@
fi

 

posted @ 2019-10-24 19:05  超我  阅读(2004)  评论(0编辑  收藏  举报