Title: Continuous Deployment with Gerrit and Jenkins
1Continuous Deployment with Gerrit and Jenkins
- R. Tyler Croy
- Lookout, Inc.
- http//mylookout.com/about/jobs
2Who is this guy?
3I work here
4(No Transcript)
5(No Transcript)
6(No Transcript)
7- 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
8Continuous Deployment
9What it isn't
10(No Transcript)
11What it is
12Who is using it?
13Why Code Review?
14Why Code Review?
15Meet Gerrit
16(No Transcript)
17As a code review tool
18As a code review tool
19As 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 gerritttyclock
- branch refs/changes/04/4/1 -gt
FETCH_HEAD - git cherry-pick FETCH_HEAD
- Finished one cherry-pick.
- change-4 1d4351c Greatly improve the stability
of tty-clock - 1 files changed, 3 insertions(), 0 deletions(-)
-
20As a collaboration tool
21As a collaboration tool
22As a collaboration tool
23As a collaboration tool
24Code Review Points
25Code Review Points
26Changes in Gerrit
27Changes in Gerrit
28(No Transcript)
29Developer Workflow
30The Gerrit Flow
gerrit
upstream
dev-a
dev-b
31Flow of changes
Create Local Branch
git checkout -b topic-branch
work
Push to Gerrit
git push gerrit HEADrefs/for/master
32Flow of changes
Create Local Branch
git checkout -b topic-branch
work
Push to Gerrit
git push gerrit HEADrefs/for/master
33Flow of changes
Create Local Branch
Fix commit
work
rejected
rebased!
Review
Push to Gerrit
Upstream repo
approved/ submitted
34Flow of changes
Create Local Branch
Fix commit
work
rejected
rebased!
Review
Push to Gerrit
Upstream repo
approved/ submitted
35Your development workflow in commands
- git checkout -b local-topic-branch
- work work work
- git rebase -i upstream/master fix up commits
- git push gerrit HEADrefs/for/master
- Create new commits based on reviews
- git rebase -i upstream/master squash up
- git push gerrit HEADrefs/for/master
36REBASE IS SCARY (but necessary)
37How it works
upstream/master
A
B
C
git rebase upstream/master
local-topic-branch
A
B
D
E
38How it works
upstream/master
A
B
C
local-topic-branch
A
B
C
D
E
39How it works
upstream/master
A
B
C
git rebase -i upstream/master
local-topic-branch
A
B
C
D
E
Change-Id Icde43
Change-Id I51bdc2
40 git rebase -i origin/master pick e59df21
Greatly improve the stability of tty-clock squash
6c1ffe1 Fix some whitespace detached HEAD
785692b Greatly improve the stability of
tty-clock 1 files changed, 2 insertions(), 0
deletions(-) Successfully rebased and updated
refs/heads/change-4.
41How it works
upstream/master
A
B
C
local-topic-branch
A
B
C
DE
Change-Id Icde43
42How it works
upstream/master
A
B
C
local-topic-branch
A
B
C
DE
Change-Id Icde43
43Gerrit Trigger Plugin
44Creating a role account
- ssh gerrit gerrit create-account
45Commands sent over SSH
Streamed events over SSH
46(No Transcript)
47A simple pipeline
48Creating a Jenkins verifier job
49Creating a Jenkins verifier job
50Creating a Jenkins verifier job
51Flow of changes
Create Local Branch
Build Fails! (-1, Not Verified)
Fix commit
work
Verification Job
Success! (1, Verified)
Review
Push to Gerrit
Upstream repo
52Flow of changes
Create Local Branch
Build Fails! (-1, Not Verified)
Fix commit
work
Verification Job
Success! (1, Verified)
Review
Push to Gerrit
Upstream repo
53Deployment
gerrit
upstream
Release Build
dev-a
dev-b
Release Test
Release Deploy
54Deployment
upstream
Release Build
Downstream Job
Release Test
Downstream Job
Release Deploy
rsync/ cap/ scp/ mvn
55Deployment
upstream
Release Build
Downstream Job
Release Test
Downstream Job
Release Deploy
rsync/ cap/ scp/ mvn
56Multiple Branches
57Creating the branches in Gerrit
58Creating the branches in Gerrit
git push gerrit release-1.0
59From the developer point of view
git checkout -b relfix track
upstream/release-1.0 work work work git
add/commit git push gerrit HEADrefs/for/relea
se-1.0
60From the Jenkins point of view
61From the Jenkins point of view
62(No Transcript)
63The Human Factor
64Working with changes in review
65Working 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
66Working with in-review changes
Developer 1
A
B
C1
Developer 2
A
B
C1
D
E
67Working with in-review changes
Developer 1
A
B
C2
Developer 2
A
B
C1
D
E
68Working with in-review changes
Upstream
A
B
B
C2
Developer 2
A
B
C1
D
E
69Working 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... Falling back to
patching base and 3-way merge... Auto-merging
ttyclock.c CONFLICT (content) Merge conflict in
ttyclock.c Failed to merge in the changes. Patch
failed at 0001 Unused variable When you have
resolved this problem run "git rebase
--continue". If you would prefer to skip this
patch, instead run "git rebase --skip". To
restore the original branch and stop rebasing run
"git rebase --abort". git rebase --skip HEAD
is now at edff388 Unused variable Applying Local
change
70Working with in-review changes
Upstream
A
B
C2
Developer 2
A
B
C2
D
E
71Picking up changes
Developer 1
A
B
C1
Developer 2
A
B
C1
72Picking up changes
Developer 1
A
B
C1
Developer 2
A
B
C2
73Performing manual verification by QA
74Manual verification
75Kick-off deployments with the Promoted Builds
plugin
76(No Transcript)
77(No Transcript)
78Pro Tips
79Use squash or fixup to condense changes
80Create per-topic/ticket local branches for
clearer isolation of work
81Multiple jobs with the same trigger criteria
82Investigate the EC2 plugin for burstable testing
capacity
83Gotchas and Errata
84(No Transcript)
85Dependencies in Gerrit
86Dependencies in Gerrit
87Dependencies in Gerrit
88Final Thoughts
89Final Thoughts
90Final Thoughts
91Final Thoughts
92Final Thoughts
93Thank You To Our Sponsors
94QA and Links
- Gerrit http//code.google.com/p/gerrit
- Gerrit Trigger Plugin http//urlenco.de/oyhmac
- These slides (w/ notes) http//urlenco.de/vhqjl