Continuous Integration
SaaS vs Jenkins in cloud
GLUTEN
FREE
Alessandro Mazzoli
alendmazz
am@ideato.it
Who am I?
sysadmin@ideato
AWS solution architect
Why I should prefer
on premise Jenkins
vs SaaS
like Travis or CircleCI?
What is Jenkins?
Jenkins is a famous
cross-platform,
continuous integration
and continuous delivery
application
cross platform
support SCM tools
released under MIT license
Java based (war file)
job execution monitoring
reports, notifications
rich of plugins(Docker,
Github, Slack, Build Pipeline)
hooks, triggers, conditionals
Let’s talk about $$$
170 US$
130 US$
Travis Startup AWS c4.xlarge
costs estimated on demand c4.xlarge up for 24h/day
I have also to
configure and
maintain Jenkins…
switch on/off
every day???!!
Waste
Boring
Stressful
AWS CLI + CRONJOBS
!/bin/bash
EC2_ID=i-abcdefgh
EIP=52.*.*.*.
IAM=ideato_jenkins

aws ec2 start-instances --instance-ids ${EC2_ID}
profile ${IAM}
aws ec2 associate-address --instance-id ${EC2_ID}
--public-ip ${EIP} --profile ${IAM}


exit 0
jenkins_on.sh
!/bin/bash
EC2_ID=i-abcdefgh
IAM=ideato_jenkins

aws ec2 stop-instances --instance-ids ${EC2_ID}
—profile ${IAM}
exit 0
jenkins_off.sh
Let’s talk again about $$$
54 US$
130 US$
Travis Startup AWS c4.xlarge
costs estimated on demand c4.xlarge up for 8h/day
Save more
money?
Put your Jenkins on
Reserved Instances
Reserved Instances
capacity
reservation
for one or
three years
inside an AZ
help AWS on
capacity
planning
hourly billing
rate lower
Reserved Instances
switch AZ within
the same region
Change the
instance size
within the same
instance type
not just
EC2
billing
mechanism
Reserved Instances
reservation
cannot be
refundable
applied to a
single
instance types
restricted
inside a region
Reserved Instances
all upfront 3y save up
70%
all upfront 1y save up
30%
Let’s talk again about $$$
34 US$
130 US$
Travis Startup AWS c4.xlarge
costs estimated on reserved 1y upfront
c4.xlarge up for 8h/day
Ok but….
different stacks?!
• OS (Debian vs RedHat)
• PHP(5.x), Java, Python
• Elasticsearch(0.9->1.7)
• Mongo
• MySQL,PostgreSQL
On Travis I just
have to edit

.travis.yaml
~= Python virtualenv
not suited for CI
system
one virtualenv active
at once
Containers history
1979 - chroot
unix syscall to change
root directory
of a process to a new location
only visible by that process
Containers history
2007 - cgroups
used for limiting, isolating and
accounting
defining CPU, RAM, I/O
Containers history
2008 - LXC
first implementation of Linux
containers with several features:
cgroups, namespace, CAP,
API bindings on Ruby,Python..
Containers history
2013 - Docker
it’s a
container
technology
was LXC
isolation
encapsulation
portability
was LXC
now runc
(Open Container Initiative)
difference
between VM &
Docker??
Containers vs VMs
AUFS
Advanced Unification FileSystem
Layered FS
Copy on Write
enable Docker Image layers
Docker Images
read only layer
used to be containers
composed by layers
Our Docker Images
Our Docker Images
FROM ubuntu:trusty	
RUN apt-get install -yq 
software-properties-common 
python-software-properties 
git 
vim 
wget 
curl
Our Docker Images
Our Docker Images
FROM ideato/trusty	
ENV DEBIAN_FRONTEND noninteractive
RUN add-apt-repository -y ppa:ondrej/php5	
RUN apt-get install -yq --no-install-recommends 
php5 
php5-cli 
php5-common 
php5-dev 
php5-gd 
php5-curl 
php5-mcrypt 
libapache2-mod-php5
Our Docker Images
Our Docker Images
FROM ideato/trusty_php:5.5
RUN apt-get install -yq mysql-server-5.5
RUN wget https://phar.phpunit.de/
phpunit.phar
RUN chmod +x phpunit.phar
RUN mv phpunit.phar /usr/local/bin/phpunit
Workflow…
projects should
have their
Dockerfile
Workflow..
these Dockerfiles
should be built on
top of CI Images
Our Docker Images
Example Project
FROM ideato/trusty_php_CI:5.5	
ENV DB default
RUN apt-get install -yq 
npm 
openjdk-7-jre 
openjdk-7-jdk 
nodejs
RUN wget https://download.elastic.co/elasticsearch/
elasticsearch/elasticsearch-1.7.3.deb
RUN dpkg -i elasticsearch-1.7.3.deb
ADD bin/run_tests /
ENTRYPOINT [“./bin/run_tests”]
Example Project
#!/bin/bash
cd /exampleproj/workspace	
service mysql start
service elasticsearch start
bin/idx build
Our Jenkins
web hook
Our Jenkins
web hook
docker build -q -t
ideato:exampleproj
-f Dockerfile .
Our Jenkins
web hook
docker build -q -t
ideato:exampleproj -
f Dockerfile .
docker run --rm=true
-v $WORKSPACE:/example_project
-t ideato:exampleproj
Our Jenkins
web hook
docker build -q -t
ideato:exampleproj -
f Dockerfile .
docker run --rm=true
-v $WORKSPACE:/example_project
-t ideato:exampleproj
channel
notification

Resuming….
1 day for Jenkins setup
~ 280$
(one time cost)
+
AWS c4.xlarge 34$ x 12 ~ 600$
vs
TravisCI Startup Plan 130€ x 12 = 1560$
oh wait…
~ 1/3 build time
than Travis
in the next few
months…
built in support for
delivery pipelines
pipeline as code
Jenkinsfile!!!
better UX on
pipeline
finally batteries
included
fully backward
compatible
try it !
docker pull jenkinsci/
jenkins:2.0-alpha-3
what else?
on dev we are using
OSX + Vagrant + Ansible
and no Docker atm
why?
Add more complexity
to FE devs

customers won’t pay
to migrate old projects
no native support
until now…
https://blog.docker.com/2016/03/
docker-for-mac-windows-beta/
no more VirtualBox,
native hypervisor support
Mac -> xhyve
Windows -> HyperV
on Mac,
Docker Engine will run
inside a Alpine Linux
on top of xhyve
native
Windows/Mac app
on OSX….
volume mounting for
code/data
with auto update
on file changes
(GIT, Sublime,PhpStorm)
tools integrated inside Docker
Toolbox
Docker Engine, Docker Compose,
Kitematic
Links
JenkinsCI
Jenkins 2.0
AWS Reserved Instances
Docker
Docker on OSX & Windows
Thanks!
Questions ??

Continuous Integration: SaaS vs Jenkins in Cloud