Sunteți pe pagina 1din 94

Jenkins User Conference

San Francisco, Oct 2nd 2011

Continuous Deployment
with Gerrit and Jenkins

R. Tyler Croy
Lookout, Inc.
http://mylookout.com/about/j
obs

Jenkins User Conference

San Francisco, Oct 2nd 2011

Who is this guy?

Jenkins User Conference

San Francisco, Oct 2nd 2011

I work here

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Brief overview of Continuous Deployment

Meet Gerrit

A Basic Commit-to-Deploy Pipeline

Multiple branches with Gerrit + Jenkins

The Human Factor

Pro-tips/best practices

Jenkins User Conference

San Francisco, Oct 2nd 2011

Continuous Deployment

Jenkins User Conference

What it isn't

San Francisco, Oct 2nd 2011

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

10

Jenkins User Conference

What it is

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Who is using it?

Jenkins User Conference

San Francisco, Oct 2nd 2011

Why Code Review?

Jenkins User Conference

San Francisco, Oct 2nd 2011

Why Code Review?

Jenkins User Conference

Meet Gerrit

San Francisco, Oct 2nd 2011

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

16

Jenkins User Conference

San Francisco, Oct 2nd 2011

As a code review tool

10/2/11

17

Jenkins User Conference

San Francisco, Oct 2nd 2011

As a code review tool

10/2/11

18

Jenkins User Conference

San Francisco, Oct 2nd 2011

As a Git repository server

~ % git checkout -b change-4


Switched to a new branch 'change-4'
~ % git fetch gerrit refs/changes/04/4/1
From gerrit:ttyclock
* branch

refs/changes/04/4/1 -> FETCH_HEAD

~ % git cherry-pick FETCH_HEAD


Finished one cherry-pick.
[change-4 1d4351c] Greatly improve the stability of ttyclock
1 files changed, 3 insertions(+), 0 deletions(-)
~ %

Jenkins User Conference


As a collaboration tool

San Francisco, Oct 2nd 2011

Jenkins User Conference


As a collaboration tool

San Francisco, Oct 2nd 2011

Jenkins User Conference


As a collaboration tool

San Francisco, Oct 2nd 2011

Jenkins User Conference


As a collaboration tool

San Francisco, Oct 2nd 2011

Jenkins User Conference


Code Review Points

San Francisco, Oct 2nd 2011

Jenkins User Conference


Code Review Points

San Francisco, Oct 2nd 2011

Jenkins User Conference


Changes in Gerrit

Change 123
Patchset 1
Commit cdeb34

Patchset 2
Commit 41dbe5

San Francisco, Oct 2nd 2011

Jenkins User Conference


Changes in Gerrit

Change 123
Patchset 1
Commit cdeb34

Patchset 2
Commit 41dbe5

San Francisco, Oct 2nd 2011

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

28

Jenkins User Conference

San Francisco, Oct 2nd 2011

Developer Workflow

Jenkins User Conference

San Francisco, Oct 2nd 2011

The Gerrit Flow

gerrit

dev-b

dev-a

upstream

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

% git checkout -b topic-branch

work

Push
to
Gerrit

% git push gerrit HEAD:refs/for/master

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

% git checkout -b topic-branch

work

Push
to
Gerrit

% git push gerrit HEAD:refs/for/master

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

work

Fix
commit

rejected

rebased!
Push
to
Gerrit

Review

approved/
submitted

Upstream repo

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

work

Fix
commit

rejected

rebased!
Push
to
Gerrit

Review

approved/
submitted

Upstream repo

Jenkins User Conference

San Francisco, Oct 2nd 2011

Your development workflow in commands

git checkout -b local-topic-branch

work work work

git rebase -i upstream/master # fix up commits

git push gerrit HEAD:refs/for/master

Create new commits based on reviews

git rebase -i upstream/master # squash up

git push gerrit HEAD:refs/for/master

Jenkins User Conference

San Francisco, Oct 2nd 2011

REBASE IS SCARY
(but necessary)

Jenkins User Conference

San Francisco, Oct 2nd 2011

How it works

upstream/master
A

% git rebase upstream/master

local-topic-branch
A

Jenkins User Conference

San Francisco, Oct 2nd 2011

How it works

upstream/master
A

local-topic-branch
A

Jenkins User Conference

San Francisco, Oct 2nd 2011

How it works

upstream/master
A

% git rebase -i upstream/master

local-topic-branch
A

D
Change-Id: Icde43

E
Change-Id: I51bdc2

Jenkins User Conference

San Francisco, Oct 2nd 2011

~ % git rebase -i origin/master

pick e59df21 Greatly improve the stability


of tty-clock
squash 6c1ffe1 Fix some whitespace

Jenkins User Conference

San Francisco, Oct 2nd 2011

How it works

upstream/master
A

local-topic-branch
A

DE
Change-Id: Icde43

Jenkins User Conference

San Francisco, Oct 2nd 2011

How it works

upstream/master
A

local-topic-branch
A

DE
Change-Id: Icde43

Jenkins User Conference

San Francisco, Oct 2nd 2011

Gerrit Trigger Plugin

Jenkins User Conference

San Francisco, Oct 2nd 2011

Creating a role account

~ % ssh gerrit gerrit create-account

Jenkins User Conference

San Francisco, Oct 2nd 2011

gerrit
Commands sent
over SSH

Streamed events
over SSH

10/2/11

Jenkins

45

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

46

Jenkins User Conference

San Francisco, Oct 2nd 2011

A simple pipeline

Jenkins User Conference


Creating a Jenkins verifier job

San Francisco, Oct 2nd 2011

Jenkins User Conference


Creating a Jenkins verifier job

San Francisco, Oct 2nd 2011

Jenkins User Conference


Creating a Jenkins verifier job

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

work

Fix
commit

Build Fails!
(-1, Not Verified)

Verification
Job
Success!
(+1, Verified)

Push
to
Gerrit

Review

Upstream repo

Jenkins User Conference

San Francisco, Oct 2nd 2011

Flow of changes

Create
Local
Branch

work

Fix
commit

Build Fails!
(-1, Not Verified)

Verification
Job
Success!
(+1, Verified)

Push
to
Gerrit

Review

Upstream repo

Jenkins User Conference

San Francisco, Oct 2nd 2011

Deployment

gerrit

upstream

Release
Build
dev-b

dev-a

Release
Test
Release
Deploy

Jenkins User Conference

San Francisco, Oct 2nd 2011

Deployment

upstream

Release
Build

Downstream Job
Release
Test

Downstream Job
Release
Deploy

Production machines
rsync/
cap/
scp/
mvn

Jenkins User Conference

San Francisco, Oct 2nd 2011

Deployment

upstream

Release
Build

Downstream Job
Release
Test

Downstream Job
Release
Deploy

Production machines
rsync/
cap/
scp/
mvn

Jenkins User Conference

San Francisco, Oct 2nd 2011

Multiple Branches

Jenkins User Conference


Creating the branches in Gerrit

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Creating the branches in Gerrit

~ % git push gerrit release-1.0

Jenkins User Conference

San Francisco, Oct 2nd 2011

From the developer point of view

~ % git checkout -b relfix track


upstream/release-1.0
~ % # work work work
~ % git add/commit
~ % git push gerrit HEAD:refs/for/release1.0

Jenkins User Conference


From the Jenkins point of view

San Francisco, Oct 2nd 2011

Jenkins User Conference


From the Jenkins point of view

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

The Human Factor

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with changes in review

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

~ % git checkout -b topic-with-17


~ % git fetch gerrit refs/changes/17/17/1
~ % git cherry-pick FETCH_HEAD
~ % # work work commit work work commit

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

Developer 1
A

C1
Developer 2
A

C1

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

Developer 1
A

C2
Developer 2
A

C1

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

Upstream
A

C2

Developer 2
A

C1

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

~ $ git rebase
gerrit/master
First, rewinding head to
replay your work on top of
it...
Applying: Unused variable
Using index info to
reconstruct a base tree...

Jenkins User Conference

San Francisco, Oct 2nd 2011

Working with in-review changes

Upstream
A

C2

Developer 2
A

C2

Jenkins User Conference


Picking up changes

Developer 1
A

C1
Developer 2
A

C1

San Francisco, Oct 2nd 2011

Jenkins User Conference


Picking up changes

Developer 1
A

C1
Developer 2
A

C2

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Performing manual verification by QA

Jenkins User Conference


Manual verification

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Kick-off deployments with the Promoted


Builds plugin

10/2/11

75

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

76

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

77

Jenkins User Conference

Pro Tips

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Use squash or fixup to condense


changes

Jenkins User Conference

San Francisco, Oct 2nd 2011

Create per-topic/ticket local branches for


clearer isolation of work

Jenkins User Conference

San Francisco, Oct 2nd 2011

Multiple jobs with the same trigger criteria

Jenkins User Conference

San Francisco, Oct 2nd 2011

Investigate the EC2 plugin for burstable


testing capacity

Jenkins User Conference

San Francisco, Oct 2nd 2011

Gotchas and Errata

Jenkins User Conference

10/2/11

San Francisco, Oct 2nd 2011

84

Jenkins User Conference


Dependencies in Gerrit

San Francisco, Oct 2nd 2011

Jenkins User Conference


Dependencies in Gerrit

San Francisco, Oct 2nd 2011

Jenkins User Conference


Dependencies in Gerrit

San Francisco, Oct 2nd 2011

Jenkins User Conference

Final Thoughts

San Francisco, Oct 2nd 2011

Jenkins User Conference

Final Thoughts

San Francisco, Oct 2nd 2011

Jenkins User Conference

Final Thoughts

San Francisco, Oct 2nd 2011

Jenkins User Conference

Final Thoughts

San Francisco, Oct 2nd 2011

Jenkins User Conference

Final Thoughts

San Francisco, Oct 2nd 2011

Jenkins User Conference

San Francisco, Oct 2nd 2011

Thank You To Our Sponsors

Jenkins User Conference

San Francisco, Oct 2nd 2011

Q&A and Links

Gerrit: http://code.google.com/p/gerrit
Gerrit Trigger Plugin:
http://urlenco.de/oyhmac
These slides (w/ notes):
http://urlenco.de/vhqjl

10/2/11

94

S-ar putea să vă placă și