~utah/utah/jenkins-upgradetest-setup

« back to all changes in this revision

Viewing changes to jenkins/setup_jenkins.py

  • Committer: Parameswaran Sivatharman
  • Date: 2013-11-01 13:03:53 UTC
  • Revision ID: para.siva@canonical.com-20131101130353-nop30y7j0htmkofv
Formatting

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    parser = argparse.ArgumentParser(
69
69
        description=('Create/Update upgrade testing jenkins jobs.'),
70
70
        epilog=("For example:\n"
71
 
                "\t%(prog)s /path/to/branch "
 
71
                "\t%(prog)s -b /path/to/branch"
72
72
                " -u user -p pass -j http://jenkins:8080"
73
73
                " -B saucy"
74
 
                " -D trusty\n" ),
 
74
                " -D trusty\n"),
75
75
        formatter_class=argparse.RawDescriptionHelpFormatter)
76
 
    parser.add_argument("-b", "--branches", 
 
76
    parser.add_argument("-b", "--branches",
77
77
                        help="Path(s) to branch(es) to process")
78
78
    parser.add_argument("-d", "--dryrun", action="store_true",
79
79
                        help="Dry run mode. Don't execute jenkins commands.")
108
108
    else:
109
109
        logging.info('...without authentication')
110
110
        instance = jenkins.Jenkins(url)
111
 
 
112
111
    return instance
113
112
 
 
113
 
114
114
def _get_environment():
115
115
    base = os.path.dirname(__file__)
116
116
    return jinja2.Environment(
136
136
 
137
137
def _configure_job(instance, env, node, publish, job_args, dryrun):
138
138
    tmpl = env.get_template('config.xml.jinja2')
139
 
    cfg = tmpl.render(node=node, branch=_get_branch(), publish=publish, **job_args)
 
139
    cfg = tmpl.render(node=node,
 
140
                      branch=_get_branch(),
 
141
                      publish=publish,
 
142
                      **job_args)
140
143
    jobname = _get_job_name(job_args)
141
144
    if instance.job_exists(jobname):
142
145
        logging.info('reconfiguring job %s', jobname)
174
177
    env = _get_environment()
175
178
 
176
179
    for job_args in permutations:
177
 
        _configure_job(instance, env, args.node, args.publish, job_args, args.dryrun)
 
180
        _configure_job(instance,
 
181
                       env,
 
182
                       args.node,
 
183
                       args.publish,
 
184
                       job_args,
 
185
                       args.dryrun)
178
186
 
179
187
if __name__ == '__main__':
180
188
    main()