blob: 4e207efdf5eff37f1aeac2ceab584eed25c5adb3 [file] [log] [blame]
James E. Blairc3b8eff2013-03-06 19:38:55 -08001#!/usr/bin/env python
2# Copyright 2013 OpenStack Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16# Print commands to leave gerrit comments for every change in one of
17# Zuul's pipelines.
18
19import urllib2
20import json
21import sys
22import argparse
23
24parser = argparse.ArgumentParser()
25parser.add_argument('url', help='The URL of the running Zuul instance')
26parser.add_argument('pipeline_name', help='The name of the Zuul pipeline')
27parser.add_argument('comment', help='The text of the Gerrit comment')
28parser.add_argument('--review-host', default='review',
29 help='The Gerrit hostname')
30options = parser.parse_args()
31
32data = urllib2.urlopen('%s/status.json' % options.url).read()
33data = json.loads(data)
34
35for pipeline in data['pipelines']:
36 if pipeline['name'] != options.pipeline_name:
37 continue
38 for queue in pipeline['change_queues']:
39 for head in queue['heads']:
40 for change in head:
41 print 'ssh %s gerrit review %s --message \\"%s\\"' % (
42 options.review_host,
43 change['id'],
44 options.comment)