jenkins on docker

17
Jenkins on Docker [email protected]

Upload: craig-trim

Post on 20-Jul-2015

463 views

Category:

Technology


4 download

TRANSCRIPT

Jenkins on [email protected]

Extend

FROM jenkins

MAINTAINER Craig Trim "[email protected]"

ENV MAVEN_HOME /usr/lib/apache/maven/3.3.1

ENV PATH /usr/lib/apache/maven/3.3.1/bin:$PATH

USER root

RUN export DEBIAN_FRONTEND=noninteractive && \

apt-get update

RUN \

mkdir -p $MAVEN_HOME && \

cd $MAVEN_HOME && \

wget http://mirrors.ibiblio.org/apache/maven/maven-3/3.3.1/binaries/apache-maven-3.3.1-bin.tar.gz && \

tar -zxvf apache-maven-3.3.1-bin.tar.gz && \

mv apache-maven-3.3.1/* . && \

rm -rf apache-maven-3.3.1

USER jenkins

• Extend the official docker Jenkins file to install Maven

• Official Image• https://registry.hub.docker.com/_/jenkins/

• Extended Image• https://github.com/torrances/docker/tree/master/jenkins

Build and Launch• Build the docker image

• “craig/jenkins“

• Launch a container• Expose on port 8040 (arbitrary)• -p 8040:8080

• Inject a host directory• This will contain all the Jenkins

customizations: build configurations, credentials, workspace and built artifacts

• Around 130 MB immediately, and can become very large over time

• -v ~/jpr:/var/jenkins_home

• Code is on the next page• I like to use a shell script that handles any

host system manipulation and then calls a docker-compose script

Docker (and docker-compose) installation script:https://github.com/torrances/bash/blob/master/install/docker.sh

Build and Launch

docker-compose.ymljenkins:

build: .

ports:

- "8040:8080"

volumes:

- ~/jpr:/var/jenkins_home

hostname:

jenkins

privileged:

false

run.shmkdir ~/jpr

sudo docker-compose up

View• Pull up a web browser!

Further Configuration (creating new jobs):http://trimc-devops.blogspot.com/p/masterpage.html#jenkins

Add Maven Installation• Click on Manage Jenkins

Add Maven Installation• Click on Configure System

Add Maven Installation• Scroll down

• Click the Add Maven button

• Unselect the Install automatically checkbox

• In the Name textbox, put maven

• In the MAVEN_HOME textbox, enter the path from the Dockerfile (/usr/lib/apache/maven/3.3.1)

• Click Save

Maven Installation and Usage:http://trimc-devops.blogspot.com/p/masterpage.html#maven

Install the Git Plugin• Go back to the dashboard

• Select Manage Jenkins from the left-hand nav

• Select Manage Plugins from the list

Install the Git Plugin• Click on the Available tab

• Type github in the Filter text area

Install the Git Plugin• Scroll down and select Github Plugin

• Click Install without restart

Install the Git Plugin• Wait for the installation to complete

Install the Git Plugin• Wait for the installation to complete

Install the Git Plugin• Once the installation is complete, check

the Restart Jenkins when installation is complete and no jobs are running checkbox

Install the Git Plugin• This will immediately restart Jenkins

Thanks!

Things that I haven’t got around to doing yet …

• Look into the use of a docker host to dynamically provision a slave, run a single build, and tear down the host:• https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin

• Install plugins (like Git) dynamically• https://registry.hub.docker.com/_/jenkins/

• Do I need to install Maven on Docker first, or can this be installed automatically when Jenkins initializes?