blob: 7fc541b1efc02351e50a9afcaa002999f99e8f4e [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
James E. Blairc3b8eff2013-03-06 19:38:55 -080021import argparse
22
23parser = argparse.ArgumentParser()
24parser.add_argument('url', help='The URL of the running Zuul instance')
25parser.add_argument('pipeline_name', help='The name of the Zuul pipeline')
26parser.add_argument('comment', help='The text of the Gerrit comment')
27parser.add_argument('--review-host', default='review',
28 help='The Gerrit hostname')
29options = parser.parse_args()
30
31data = urllib2.urlopen('%s/status.json' % options.url).read()
32data = json.loads(data)
33
34for pipeline in data['pipelines']:
35 if pipeline['name'] != options.pipeline_name:
36 continue
37 for queue in pipeline['change_queues']:
38 for head in queue['heads']:
39 for change in head:
40 print 'ssh %s gerrit review %s --message \\"%s\\"' % (
41 options.review_host,
42 change['id'],
43 options.comment)