Fix "update" command.
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
This commit is contained in:
parent
1b37d05edb
commit
813fe7d5f2
@ -2,6 +2,7 @@
|
||||
|
||||
import jenkins_jobs.builder
|
||||
import argparse
|
||||
import ConfigParser
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
@ -9,7 +10,7 @@ def main():
|
||||
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_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')
|
||||
@ -22,7 +23,7 @@ def main():
|
||||
if options.conf:
|
||||
conf = options.conf
|
||||
else:
|
||||
conf = 'jenkins_jobs.ini'
|
||||
conf = '/etc/jenkins_jobs/jenkins_jobs.ini'
|
||||
|
||||
if not options.command == 'test':
|
||||
conffp = open(conf, 'r')
|
||||
@ -36,9 +37,9 @@ def main():
|
||||
config.get('jenkins','password'))
|
||||
|
||||
if options.command == 'delete':
|
||||
builder.delete_job()
|
||||
builder.delete_job(options.name)
|
||||
elif options.command == 'update':
|
||||
builder.update_job()
|
||||
builder.update_job(options.path, options.name)
|
||||
elif options.command == 'test':
|
||||
builder.update_job(options.path, options.name,
|
||||
output_dir=options.output_dir)
|
||||
|
@ -229,8 +229,8 @@ class Builder(object):
|
||||
self.jenkins = Jenkins(jenkins_url, jenkins_user, jenkins_password)
|
||||
self.cache = CacheStorage()
|
||||
|
||||
def delete_job(self):
|
||||
self.jenkins.delete_job(options.name)
|
||||
def delete_job(self, name):
|
||||
self.jenkins.delete_job(name)
|
||||
|
||||
def update_job(self, fn, name=None, output_dir=None):
|
||||
if os.path.isdir(fn):
|
||||
@ -249,9 +249,6 @@ class Builder(object):
|
||||
if name and job.name != name:
|
||||
continue
|
||||
if output_dir:
|
||||
#print '='*70
|
||||
#print job.name
|
||||
#print '-'*70
|
||||
if name:
|
||||
print job.output()
|
||||
continue
|
||||
@ -261,13 +258,13 @@ class Builder(object):
|
||||
f.close()
|
||||
continue
|
||||
md5 = job.md5()
|
||||
if (remote_jenkins.is_job(job.nam)
|
||||
if (self.jenkins.is_job(job.name)
|
||||
and not self.cache.is_cached(job.name)):
|
||||
old_md5 = remote_jenkins.get_job_md5(job.name)
|
||||
old_md5 = self.jenkins.get_job_md5(job.name)
|
||||
self.cache.set(job.name, old_md5)
|
||||
|
||||
if self.cache.has_changed(job.name, md5):
|
||||
remote_jenkins.update_job(job.name, xml.output())
|
||||
self.jenkins.update_job(job.name, job.output())
|
||||
self.cache.set(job.name, md5)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user