continuous delivery with docker and jenkins job builder

Post on 28-Jul-2015

723 Views

Category:

Software

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Continuous Deliverywith

Docker &Jenkins Job Builder

Wouter Lagerweij@wouterla

Prepare!

See the Readme.html in the main directory:● copy contents of usb stick to harddrive● open workshop-docker-jenkins dir● type ‘vagrant up’● type ‘vagrant ssh’● type ‘docker ps’

The Goal

Pipeline view at Persgroep Online Services

The Goal

Automate Everything

● Everything in version control○ Including infrastructure○ Build server and configuration○ Deployment scripts

We are going to...

● Automate creation of Jenkins Jobs● Automate creation of deployment package

(Docker container)● Automate deployment of Docker container● Automate creation of full Delivery Pipeline in

Jenkins

Using

● Jenkins ● Jenkins Job Builder● Docker● Bash;-)

docker run$ docker run -d -v /home/vagrant/.m2:/root/.m2

-v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 --name jenkins wouterla/docker-jenkins

● ports: -p <host-port>:<container-port>● volumes: -v <host-dir>:<container-dir>● -d: background● --name: to find it by● Image: <repository>/<name>:<tag>

https://docs.docker.com/reference/commandline/cli/

Docker stop

docker stop <name>docker stop <container-id>docker rm <name>

docker ps

Work

Start Jenkins container on port 8081

then

Stop, and switch back to 8080

Running Jenkins Job Builder

docker run wouterla/docker-jenkins-job-builder

Needs access to jenkins!

docker run --link jenkins:jenkins wouterla/docker-jenkins-job-builder

● link: <container-name>:<alias>

Our pipeline

Jenkins Job Builder

● Jobs● Projects● Job Templates● Variables

Variable types and scope

● project -> template● defaults● YAML references● macros● within and across files

Project / template

YAML references

Macros

Work

Add a new step to the pipeline that runs the maven ‘install’ goal

Docker build

● -t <repository>/<name>:<tag>● . (or -f)

But today:

$> ./build_docker_jenkins_job_builder.sh

Dockerfile

Work

Complete the Dockerfile for demo app, and build it locally

Hint: You can run the app with:java -jar jetty-runner.jar <war-file>

Dockerfile

Docker push/pull

● login● push <tag>● pull <tag>

Work

Add step to pipeline that builds the docker image for our demo app

Work

● Add ‘test’ phase to pipeline● Add step that deploys demo app on port

8081

Work

Add ‘production’ phase and environment running on port 8082

Work

Add second pipeline, building ‘workshop’ branch

Work

Add ‘smoketest’ step to test and production phase

top related