使用Docker进行Jenkins持续集成

Jenkins集成

$ mkdir jenkins

$ cd jenkins

起一个Dockerfile, 顺手把ubuntu的repo也放一起

 

FROM ubuntu:16.04

MAINTAINER zunly@hotmail.com

ENV REFRESHED_AT 2019-02-05

 

RUN mv /etc/apt/sources.list /etc/apt/sources.list.back

ADD sources.list /etc/apt/sources.list

 

RUN apt-get update

RUN apt-get install -y curl apt-transport-https wget git-core openjdk-8-jdk

RUN apt-get install -y iptables ca-certificates 

RUN wget -qO- https://get.docker.com/ | sh

RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

 

ENV JENKINS_HOME /opt/jenkins/data

ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org

 

RUN mkdir -p /opt/jenkins/data/plugins

RUN curl -f -o /opt/jenkins/jenkins.war -L http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war

 

RUN for plugin in chucknorris greenballs scm-api git-client git ws-cleanup;\

      do curl -sf -o /opt/jenkins/data/plugins/${plugin}.hip \

       -L http://mirrors.jenkins-ci.org/plugins/${plugin}/latest/${plugin}.hpi; done

 

ADD ./dockerjenkins.sh /usr/local/bin/dockerjenkins.sh

RUN chmod +x /usr/local/bin/dockerjenkins.sh

 

VOLUME /var/lib/docker

 

EXPOSE 8080

 

ENTRYPOINT ["/usr/local/bin/dockerjenkins.sh"]

 

使用build建image

sudo docker build -t zunly/dockerjenkins .

 

使用run 启动容器

$ sudo docker run -p 8080:8080 --name jenkins --privileged -d zunly/dockerjenkins

用logs查看安装密码

$ sudo docker logs -f jenkins

 

posted @ 2019-02-05 11:43  Montauk  阅读(193)  评论(0编辑  收藏  举报