= Talk about Jenkins 2 Pipeline with Docker for Maven CI :toc: :toclevels: 4 :images: ./ ifdef::env-github[] :status: :outfilesuffix: .adoc :!toc-title: :caution-caption: :fire: :important-caption: :exclamation: :note-caption: :paperclip: :tip-caption: :bulb: :warning-caption: :warning: endif::[]
This repository contains all resources about this talk:
*slides*
: sources for AsciiDoc slides*docs*
: public files, slides HTML (assets, html...)*demo*
: docker compose files and doc to run the demo== How to work on slides with livereload feature?
+
. Edit slides (.adoc
files) in slides/src/
. Save
. Refresh your browser and enjoy ;)
== Run the Demo
=== Start Jenkins2 / Sonar containers
$ docker network create --driver bridge swf
$ docker-compose -f demo/sonar/docker-compose.yml up
$ docker-compose -f demo/jenkins2/docker-compose.yml up $ open http://localhost:8888
=== Configure the Jenkins instance
A lot of configuration is loaded by default in the mgreau/jenkins
Docker image, but some configuration have to be done once Jenkins is started.
==== Create an Agent (ci-agent))
ci-agent
... Description:: Agent used to execute Build in Docker containers
... Remote root directory:: jenkins-agents/ci-agent
+
[NOTE]+
... Labels:: *ci-docker*
... Launch method:: Launch slave agents on Unix machines via SSH
.... Host:: Your IP (no 127.0.0.1 neither localhost)
.... Credentials:: Add new credentials with your username/pwd
.... Advanced > Prefix Start Slave Command:: source ~/.bash_profile &&
[IMPORTANT]
Required so that Jenkins can load your PATH to be able to access the docker binary
=== Configure SMTP server (embedded MailHog)
In order to receive builds status by email, you need to configure, got to http://localhost:8888/configure#section20[Extended E-mail Notification Configuration]
[horizontal] SMTP server:: smtp SMTP Port:: 1025 Charset:: UTF-8
=== Execute the default Pipeline/Maven/Docker build
By default, a Jenkns Pipeline job is created at http://localhost:8888/job/javaee7-websocket-master-ci/
It will build a Maven Java EE 7 project in a exoplatform/ci:jdk8-maven32
Docker container.+
=== Advanced configuration
==== Maven Settings file
If you want to customize the Maven Settings file included in each container:
. Update the Maven configuration file (settings.xml with ID exo-ci-maven-settings
)
.. Go to http://localhost:8888/configfiles/editConfig?id=exo-ci-maven-settings
.. Update the Maven XML config file with your configuration
+
image::./demo/images/jenkins-setup-maven-config-xml.png[]
+
==== Create your first Pipeline Docker job
@Library('github.com/mgreau/exo-pipeline-library@master') // <1> import exoCI // <2>
node('ci-docker'){
exoCI{
gitUrl = 'https://github.com/mgreau/javaee7-websocket.git'
gitBranch = 'master'
dockerImage = 'exoplatform/ci:jdk8-maven32'
mavenGoals = 'clean package'
}