def configure_ci_job(<EOL>config_url, rosdistro_name, ci_build_name,<EOL>os_name, os_code_name, arch,<EOL>config=None, build_file=None,<EOL>index=None, dist_file=None,<EOL>jenkins=None, views=None,<EOL>is_disabled=False,<EOL>groovy_script=None,<EOL>build_targets=None,<EOL>dry_run=False,<EOL>underlay_source_paths=None,<EOL>trigger_timer=None):
if config is None:<EOL><INDENT>config = get_config_index(config_url)<EOL><DEDENT>if build_file is None:<EOL><INDENT>build_files = get_ci_build_files(config, rosdistro_name)<EOL>build_file = build_files[ci_build_name]<EOL><DEDENT>if build_targets is not None:<EOL><INDENT>build_file.targets = build_targets<EOL><DEDENT>if index is None:<EOL><INDENT>index = get_index(config.rosdistro_index_url)<EOL><DEDENT>if dist_file is None:<EOL><INDENT>dist_file = get_distribution_file(index, rosdistro_name, build_file)<EOL>if not dist_file:<EOL><INDENT>raise JobValidationError(<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>if os_name not in build_file.targets.keys():<EOL><INDENT>raise JobValidationError(<EOL>"<STR_LIT>" % os_name +<EOL>'<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(sorted(build_file.targets.keys())))<EOL><DEDENT>if os_code_name not in build_file.targets[os_name].keys():<EOL><INDENT>raise JobValidationError(<EOL>"<STR_LIT>" % os_code_name +<EOL>'<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(sorted(build_file.targets[os_name].keys())))<EOL><DEDENT>if arch not in build_file.targets[os_name][os_code_name]:<EOL><INDENT>raise JobValidationError(<EOL>"<STR_LIT>" % arch +<EOL>'<STR_LIT>' % '<STR_LIT:U+002CU+0020>'.join(sorted(<EOL>build_file.targets[os_name][os_code_name])))<EOL><DEDENT>if len(build_file.underlay_from_ci_jobs) > <NUM_LIT:1>:<EOL><INDENT>raise JobValidationError(<EOL>'<STR_LIT>' +<EOL>'<STR_LIT>' % len(build_file.underlay_from_ci_jobs))<EOL><DEDENT>underlay_source_job = None<EOL>if build_file.underlay_from_ci_jobs:<EOL><INDENT>underlay_source_job = get_ci_job_name(<EOL>rosdistro_name, os_name, os_code_name, arch,<EOL>build_file.underlay_from_ci_jobs[<NUM_LIT:0>])<EOL>underlay_source_paths = (underlay_source_paths or []) +['<STR_LIT>']<EOL><DEDENT>if jenkins is None:<EOL><INDENT>from ros_buildfarm.jenkins import connect<EOL>jenkins = connect(config.jenkins_url)<EOL><DEDENT>if views is None:<EOL><INDENT>view_name = get_ci_view_name(rosdistro_name)<EOL>configure_ci_view(jenkins, view_name, dry_run=dry_run)<EOL><DEDENT>job_name = get_ci_job_name(<EOL>rosdistro_name, os_name, os_code_name, arch, ci_build_name)<EOL>job_config = _get_ci_job_config(<EOL>index, rosdistro_name, build_file, os_name,<EOL>os_code_name, arch,<EOL>build_file.repos_files,<EOL>underlay_source_job,<EOL>underlay_source_paths,<EOL>trigger_timer,<EOL>is_disabled=is_disabled)<EOL>if isinstance(jenkins, object) and jenkins is not False:<EOL><INDENT>from ros_buildfarm.jenkins import configure_job<EOL>configure_job(jenkins, job_name, job_config, dry_run=dry_run)<EOL><DEDENT>return job_name, job_config<EOL>
Configure a single Jenkins CI job.

This includes the following steps:
- clone the ros_buildfarm repository
- write the distribution repository keys into files
- invoke the ci/run_ci_job.py script