813fe7d5f2
Some untested code after the recent refactor was broken. Change-Id: Id8cf33b3d67d86fc18253d8fc91875669a888540 Reviewed-on: https://review.openstack.org/11197 Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
49 lines
1.8 KiB
Python
Executable File
49 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import jenkins_jobs.builder
|
|
import argparse
|
|
import ConfigParser
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
subparser = parser.add_subparsers(help='update, test or delete job',
|
|
dest='command')
|
|
parser_update = subparser.add_parser('update')
|
|
parser_update.add_argument('path', help='Path to YAML file or directory')
|
|
parser_update.add_argument('name', help='name of job', nargs='?')
|
|
parser_test = subparser.add_parser('test')
|
|
parser_test.add_argument('path', help='Path to YAML file or directory')
|
|
parser_test.add_argument('-o', dest='output_dir', help='Path to output XML')
|
|
parser_test.add_argument('name', help='name of job', nargs='?')
|
|
parser_delete = subparser.add_parser('delete')
|
|
parser_delete.add_argument('name', help='name of job')
|
|
parser.add_argument('--conf', dest='conf', help='Configuration file')
|
|
options = parser.parse_args()
|
|
|
|
if options.conf:
|
|
conf = options.conf
|
|
else:
|
|
conf = '/etc/jenkins_jobs/jenkins_jobs.ini'
|
|
|
|
if not options.command == 'test':
|
|
conffp = open(conf, 'r')
|
|
config = ConfigParser.ConfigParser()
|
|
config.readfp(conffp)
|
|
else:
|
|
config = {}
|
|
|
|
builder = jenkins_jobs.builder.Builder(config.get('jenkins','url'),
|
|
config.get('jenkins','user'),
|
|
config.get('jenkins','password'))
|
|
|
|
if options.command == 'delete':
|
|
builder.delete_job(options.name)
|
|
elif options.command == 'update':
|
|
builder.update_job(options.path, options.name)
|
|
elif options.command == 'test':
|
|
builder.update_job(options.path, options.name,
|
|
output_dir=options.output_dir)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|