blob: d2583546d5863d976bd641a55515bd6e6a6d914b [file] [log] [blame]
James E. Blairc3b8eff2013-03-06 19:38:55 -08001#!/usr/bin/env python
2# Copyright 2013 OpenStack Foundation
James E. Blair574ec762015-02-27 13:50:31 -08003# Copyright 2015 Hewlett-Packard Development Company, L.P.
James E. Blairc3b8eff2013-03-06 19:38:55 -08004#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
James E. Blairc3b8eff2013-03-06 19:38:55 -080017import urllib2
18import json
James E. Blairc3b8eff2013-03-06 19:38:55 -080019import argparse
20
21parser = argparse.ArgumentParser()
22parser.add_argument('url', help='The URL of the running Zuul instance')
James E. Blaird05469e2017-09-29 09:04:15 -070023parser.add_argument('tenant', help='The Zuul tenant')
24parser.add_argument('pipeline', help='The name of the Zuul pipeline')
James E. Blairc3b8eff2013-03-06 19:38:55 -080025options = parser.parse_args()
26
27data = urllib2.urlopen('%s/status.json' % options.url).read()
28data = json.loads(data)
29
30for pipeline in data['pipelines']:
James E. Blaird05469e2017-09-29 09:04:15 -070031 if pipeline['name'] != options.pipeline:
James E. Blairc3b8eff2013-03-06 19:38:55 -080032 continue
33 for queue in pipeline['change_queues']:
34 for head in queue['heads']:
35 for change in head:
James E. Blair574ec762015-02-27 13:50:31 -080036 if not change['live']:
37 continue
38 cid, cps = change['id'].split(',')
Morgan Fainberg4c6a7742016-05-27 08:42:17 -070039 print(
James E. Blaird05469e2017-09-29 09:04:15 -070040 "zuul enqueue --tenant %s --trigger gerrit "
41 "--pipeline %s --project %s --change %s,%s" % (
42 options.tenant,
43 options.pipeline,
James E. Blair574ec762015-02-27 13:50:31 -080044 change['project'],
45 cid, cps)
46 )