Git, Gerrit and Jenkins

B3d3a2cce932eca144b8c13a63966404?s=47 alblue
October 20, 2011

Git, Gerrit and Jenkins

A talk on combining Git, Gerrit and Jenkins, based on existing material delivered via this blog post:

http://alblue.bandlem.com/2011/02/gerrit-git-review-with-jenkins-ci.html
http://vimeo.com/20084957

B3d3a2cce932eca144b8c13a63966404?s=128

alblue

October 20, 2011
Tweet

Transcript

  1. 1.

    Git, Gerrit and Jenkins Code Review and Automated Build Alex

    Blewitt @alblue SkillsMatter October 2011
  2. 2.

    Git • Matthew has talked about Git extensively • Ask

    @matthewmccull for more details :) • Alternatively look for Git Tip of the Week • #gtotw • alblue.bandlem.com/search/label/gtotw
  3. 3.

    Gerrit • Git-backed review system • Used by Eclipse, Android

    • Acts as a front-end to a central Git repo • When review complete, auto-merged
  4. 4.

    Jenkins/Hudson • Automated build platform • Can be used with/without

    Gerrit/Git • Has triggers to hook into events • Hudson donated to Eclipse Foundation • Jenkins donated to SPI
  5. 6.

    Team development • Work as a team • Merge to

    centralised repository • Review all code changes ✓But without affecting others
  6. 7.

    Attempt I • Review before commit ✓No cruft in repository

    ✓Doesn’t affect others ✴No guarantee reviewed == commited
  7. 8.

    Attempt II • Review after commit ✓Guarantee reviewed == commited

    ✴Cruft in repository ✴May affect others
  8. 9.

    Attempt III • Review after commit on unique branch ✓Guarantee

    reviewed == commited ✓No cruft in repository on main branch ✓Will not affect others
  9. 10.

    Pushing • Pushing to Gerrit creates a new branch •

    master:refs/for/master • Review comments can be added to files • Can compare before/after changes • Change-Id allows patch sets per branch
  10. 12.

    Checking it out • Jenkins can be told when a

    change occurs • Can automatically compile and test code • Can generate test report • Can mark success/failure in Gerrit
  11. 13.

    Jenkins Gerrit Trigger • Can install the Gerrit Trigger Plugin

    • Automatically installs Git plugin • Set refspect to pull as $GERRIT_REFSPEC • Build Trigger as Gerrit Event • Project must match project(s) • Project Path ** Branch Path **
  12. 16.

    Permissions • Gerrit can act as a permissioned keeper •

    Merges • Push-to-branch directly (skip review) • Clone/fetching • Review/Submit
  13. 17.

    Commit Hooks • Can be configured to auto add Change-Id

    • Git • scp -P 29418 gerrit:/hooks/commit-msg • EGit • git config gerrit.createchangeid true
  14. 18.

    Merging • Can configure merge options per-project • Fast Forward

    Only • Merge If necessary • Always Merge • Cherry Pick
  15. 19.

    Review Notes • Gerrit 2.2+ stores more info in Git

    repos • Permissions are stored refs/meta/config • Inherited from All-Projects.git • Review data encoded in Git Notes • refs/notes/review • git log --show-notes=*
  16. 20.

    Future • Currently (2.2) a SQL DB is still required

    • SSH keys, user information • Project metadata • More info is moving to Git repositories • Review notes • Configuration
  17. 21.

    Git, Gerrit and Jenkins Code Review and Automated Build Alex

    Blewitt @alblue SkillsMatter October 2011