From 17c210d6202bce9ab71d5d2659b3ba96b42e0512 Mon Sep 17 00:00:00 2001 From: Steve Martinelli Date: Thu, 3 Mar 2016 03:26:33 -0500 Subject: [PATCH] do not propose a new keystone config file if already approved Borrowing from common_translation_update.sh, the config file proposal should behave the same way. if there is already an approved job, then we can wait to propose a new revision once it has been merged. Moved the original code that perfoms the check into common.sh and named it check_already_approved. Change-Id: I48180f8580a54749248a25505edbc1303457e2e4 --- jenkins/scripts/common.sh | 31 +++++++++++++++++++ jenkins/scripts/common_translation_update.sh | 27 ++-------------- .../scripts/propose_updated_config_file.sh | 5 +++ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/jenkins/scripts/common.sh b/jenkins/scripts/common.sh index 4c295e789e..d666b62da1 100644 --- a/jenkins/scripts/common.sh +++ b/jenkins/scripts/common.sh @@ -57,3 +57,34 @@ EOF COMMIT_MSG=$INITIAL_COMMIT_MSG fi } + +# Check to see if $CHANGE_ID is already approved, if it is, don't bother +# proposing another. +function check_already_approved { + local CHANGE_ID=$1 + + # If the open change an already approved, let's not queue a new + # patch but let's merge the other patch first. + # This solves the problem that when the gate pipeline backup + # reaches roughly a day, no matter how quickly you approve the new + # update it will always get sniped out of the gate by another. + # It also helps, when you approve close to the time this job is + # run. + if [ -n "$CHANGE_ID" ]; then + # Use the JSON format since it is very compact and easy to grep + change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set --format=JSON $CHANGE_ID) + # Check for: + # 1) Workflow approval (+1) + # 2) no -1/-2 by Jenkins + # 3) no -2 by reviewers + # 4) no Workflow -1 (WIP) + # + if echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"1"' \ + && ! echo $change_info|grep -q '{"type":"Verified","description":"Verified","value":"-[12]","grantedOn":[0-9]*,"by":{"name":"Jenkins","username":"jenkins"}}' \ + && ! echo $change_info|grep -q '{"type":"Code-Review","description":"Code-Review","value":"-2"' \ + && ! echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"-1"' ; then + echo "Job already approved, exiting" + exit 0 + fi + fi +} diff --git a/jenkins/scripts/common_translation_update.sh b/jenkins/scripts/common_translation_update.sh index 7070a7c460..ca9bdb53ed 100644 --- a/jenkins/scripts/common_translation_update.sh +++ b/jenkins/scripts/common_translation_update.sh @@ -173,30 +173,9 @@ EOF # exists and will always set COMMIT_MSG. setup_commit_message $FULL_PROJECT proposal-bot $branch $TOPIC "$INITIAL_COMMIT_MSG" - # If the open change an already approved, let's not queue a new - # patch but let's merge the other patch first. - # This solves the problem that when the gate pipeline backup - # reaches roughly a day, no matter how quickly you approve the new - # update it will always get sniped out of the gate by another. - # It also helps, when you approve close to the time this job is - # run. - if [ -n "$CHANGE_ID" ]; then - # Use the JSON format since it is very compact and easy to grep - change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set --format=JSON $CHANGE_ID) - # Check for: - # 1) Workflow approval (+1) - # 2) no -1/-2 by Jenkins - # 3) no -2 by reviewers - # 4) no Workflow -1 (WIP) - # - if echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"1"' \ - && ! echo $change_info|grep -q '{"type":"Verified","description":"Verified","value":"-[12]","grantedOn":[0-9]*,"by":{"name":"Jenkins","username":"jenkins"}}' \ - && ! echo $change_info|grep -q '{"type":"Code-Review","description":"Code-Review","value":"-2"' \ - && ! echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"-1"' ; then - echo "Job already approved, exiting" - exit 0 - fi - fi + # Function check_already_approved will quit the proposal process if there + # is already an approved job with the same CHANGE_ID + check_already_approved $CHANGE_ID } # Propose patch using COMMIT_MSG diff --git a/jenkins/scripts/propose_updated_config_file.sh b/jenkins/scripts/propose_updated_config_file.sh index 21e57e9ee3..de3b86a456 100755 --- a/jenkins/scripts/propose_updated_config_file.sh +++ b/jenkins/scripts/propose_updated_config_file.sh @@ -27,6 +27,11 @@ setup_git # exists and will always set COMMIT_MSG. setup_commit_message $PROJECT $USERNAME $BRANCH $TOPIC "$INITIAL_COMMIT_MSG" +# Function check_already_approved will quit the proposal process if there +# is already an approved job with the same CHANGE_ID +check_already_approved $CHANGE_ID + + tox -e genconfig RET=$? if [ "$RET" -ne "0" ] ; then