2. Extend
FROM jenkins
MAINTAINER Craig Trim "craigtrim@gmail.com"
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
3. 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
8. 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
9. Install the Git Plugin
• Go back to the dashboard
• Select Manage Jenkins from the left-hand
nav
• Select Manage Plugins from the list
10. Install the Git Plugin
• Click on the Available tab
• Type github in the Filter text area
11. Install the Git Plugin
• Scroll down and select Github Plugin
• Click Install without restart
12. Install the Git Plugin
• Wait for the installation to complete
13. Install the Git Plugin
• Wait for the installation to complete
14. Install the Git Plugin
• Once the installation is complete, check
the Restart Jenkins when installation is
complete and no jobs are running
checkbox
15. Install the Git Plugin
• This will immediately restart Jenkins
17. 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?