2013年5月6日 星期一

Gerrit auto publish and submit

$ ssh -p 29418 yan@yanxen.no-ip.org gerrit query --format JSON --current-patch-set status:open label:V=1 label:R=2 project:RWS_System

# ssh -p 29418 admin@yanxen.no-ip.org gerrit review --submit 9a48b3f46c6ddf6bbdcbe23c349802f6916bf5d1


// run after jenkins build and add comment
$ vi /home/gerrit/review_sites/hooks/comment-added
#!/usr/bin/python

# auto submit after jenkins verified
# for Gerrit 2.5

import json, sys
from subprocess import Popen, PIPE

username = "jenkins"
server = "localhost"

verified_min = 1
reviewed_min = 2

results = Popen([
"ssh", "-p", "29418", username+"@"+server, "gerrit", "query",
"--format", "JSON", "--current-patch-set", "--commit-message",
"--files" , "status:open", "label:V="+str(verified_min), "label:R="+str(reviewed_min)], stdout=PIPE).communicate()[0]

parsed = json.loads(results.split("\n")[0])

if parsed:
    commit = parsed['currentPatchSet']['revision']
    results = Popen([
"ssh", "-p", "29418", username+"@"+server,
"gerrit", "review", "--submit", commit], stdout=PIPE).communicate()[0]




Reference :
From blue skies and oceans — Configuring Gerrit to auto-submit on patch approval

沒有留言:

張貼留言