diff --git a/jenkins-jobs b/jenkins-jobs index 6e74058f5..b4d17a0d5 100755 --- a/jenkins-jobs +++ b/jenkins-jobs @@ -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) diff --git a/jenkins_jobs/builder.py b/jenkins_jobs/builder.py index 80bddbbc5..f789ea9e7 100644 --- a/jenkins_jobs/builder.py +++ b/jenkins_jobs/builder.py @@ -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)