Merge "Add launchpad bug update support to abandon script"

Jenkins 6 years ago committed by Gerrit Code Review
commit 55be865d9a

@ -292,6 +292,19 @@ If the bug report is sound, move next:
we rotate, tagging bugs with 'needs-attention' can be useful to quickly
identify what reports need further screening/eyes on.
Check for Bugs with the 'timeout-abandon' tag:
* Search for any bugs with the timeout abandon tag:
`Timeout abandon <>`_.
This tag indicates that the bug had a patch associated with it that was
automatically abandonded after a timing out with negative feedback.
* For each bug with this tag, determine if the bug is still valid and update
the status accordingly. For example, if another patch fixed the bug, ensure
it's marked as 'Fix Released'. Or, if that was the only patch for the bug and
it's still valid, mark it as 'Confirmed'.
* After ensuring the bug report is in the correct state, remove the
'timeout-abandon' tag.
You are done! Iterate.

@ -36,12 +36,14 @@ else
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function abandon_review {
local gitid=$1
local msg=$@
# echo ssh gerrit review $gitid --abandon --message \"$msg\"
unassign_and_new_bug $gitid
if [ $DRY_RUN -eq 1 ]; then
echo "Would abandon $gitid"
@ -50,6 +52,20 @@ function abandon_review {
function unassign_and_new_bug {
# unassign current assignee and set bug to 'new' status
local gitid=$1
cm=$(ssh "gerrit query $gitid --current-patch-set --format json" | jq .commitMessage)
for closes in $(echo -e $cm | grep -i "closes" | grep -i "bug" | grep -o -E '[0-9]+'); do
if [ $DRY_RUN -eq 1 ]; then
echo "Would unassign and tag 'timeout-abandon' $closes"
echo "Attempting to change status of bug $closes to New"
python "$DIR/" $closes
python - <<EOF
import urllib2

@ -0,0 +1,52 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Unassigns assignee from neutron/network bug, adds message and tag.
If you get the following exception, you need X11 and python-dbus installed:
RuntimeError: No recommended backend was available. Install
the keyrings.alt package if you want to use the non-recommended
backends. See README.rst for details.
import sys
from launchpadlib.launchpad import Launchpad
This bug has had a related patch abandoned and has been automatically \
un-assigned due to inactivity. Please re-assign yourself if you are \
continuing work or adjust the state as appropriate if it is no longer valid."
def unassign(bug_num):
launchpad = Launchpad.login_with('neutron', 'production')
b = launchpad.bugs[bug_num]
for task in b.bug_tasks:
if ('neutron' not in task.bug_target_name and
'network' not in task.bug_target_name):
# try not to interfere with non-neutron projects too much
task.assignee = None
if task.status == "In Progress":
task.status = 'New'
b.tags = b.tags + ['timeout-abandon']
b.newMessage(content=MSG_BODY, subject='auto-abandon-script')
if __name__ == '__main__':