Commit d55c5c14 authored by Robert Lyon's avatar Robert Lyon
Browse files

Allowing for jenkins to reject a failed patch

Eg. if the patch or one of it's parents has a reject status then there
is no point running the behat - we should exit out and let user know
to fix up patches first
Signed-off-by: Robert Lyon's avatarRobert Lyon <>
parent a4487752
* Using php to do the json_decode / checking of patch status
* as it is easier than trying to get bash to do it
$git_commit_id = $argv[2];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '' . $git_commit_id . '&o=LABELS&pp=0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
// We need to fetch the json line from the result
$content = explode("\n", $content);
$content = json_decode($content[1]);
// Doublecheck to see if this has already been merged
if ($content[0]->status == 'MERGED') {
echo 2;
// Now check to see if anyone has rejected this
if (empty($content[0]->labels->{'Verified'}->rejected) &&
empty($content[0]->labels->{'Code-Review'}->rejected) &&
empty($content[0]->labels->{'Automated-Tests'}->rejected)) {
echo 0;
else {
echo 1;
\ No newline at end of file
......@@ -14,6 +14,32 @@ BEHINDBY=`git rev-list HEAD..origin/$GERRIT_BRANCH | wc -l`
echo "This patch is behind master by $BEHINDBY commit(s)"
[[ "$BEHINDBY" -lt "$MAXBEHIND" ]] || { echo "This patch is too far behind master, please rebase"; exit 1; }
echo "########## Check the patch and it's parents are not already rejected"
echo ""
# Fetch the last 30 git commit ids and check the ones that are not also present in origin
# This allows us to check the current patch and it's parents all the way back to a commit
# that exists in origin, ie the point that origin HEAD was at when the patch was made. If
# there are more than 30 steps to get to origin HEAD the check above will handle that.
HEAD=`git rev-parse HEAD`
the_list=`git rev-list $HEAD...$MAXBEHINDHEAD`
while IFS= read -r line
# see if the commit doesn't already exist in origin
testcommit=`git branch -r --contains $line`
if [ -z "$testcommit" ]; then
# check if the commit or it's parents have been rejected
outcome=`php gerrit_query.php -- $line`
if [ "$outcome" = "1" ]; then
echo "This patch or one of its parents has been rejected";
exit 1;
# commit exists in origin
done <<< "$the_list"
echo ""
echo "########## Run make minaccept"
echo ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment