blob: 9dbf504e742e342a77b8b4307068e87f6334de91 [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')
23parser.add_argument('pipeline_name', help='The name of the Zuul pipeline')
James E. Blairc3b8eff2013-03-06 19:38:55 -080024options = parser.parse_args()
25
26data = urllib2.urlopen('%s/status.json' % options.url).read()
27data = json.loads(data)
28
29for pipeline in data['pipelines']:
30 if pipeline['name'] != options.pipeline_name:
31 continue
32 for queue in pipeline['change_queues']:
33 for head in queue['heads']:
34 for change in head:
James E. Blair574ec762015-02-27 13:50:31 -080035 if not change['live']:
36 continue
37 cid, cps = change['id'].split(',')
38 print (
39 "zuul enqueue --trigger gerrit --pipeline %s "
40 "--project %s --change %s,%s" % (
41 options.pipeline_name,
42 change['project'],
43 cid, cps)
44 )