jenkins-job-builder/jenkins-jobs
James E. Blair 8f09841693 Refactor modules and templating.
Switch to using entry points for loading modules as well as
individual buliders, triggers, publishers, etc.

Remove most openstack-specific python code.

Change templating so it's less repetitive -- a single project
definition will suffice for multiple jobs or job-groups.

This outputs XML that is identical to the current production XML,
warts and all.  There are significant improvements that can be made
to the YAML in a separate change, as they will cause minor changes
to existing jobs (adding timestamps, logrotate, etc.).  These are
mostly marked with TODO in this change.

Change-Id: Idcfddb3b43b6cfef4b20919a84540706d7a0a0b1
Reviewed-on: https://review.openstack.org/11000
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
2012-08-10 16:00:42 +00:00

48 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python
import jenkins_jobs.builder
import argparse
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')
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 = '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()
elif options.command == 'update':
builder.update_job()
elif options.command == 'test':
builder.update_job(options.path, options.name,
output_dir=options.output_dir)
if __name__ == '__main__':
main()