~powersj/jenkins-launchpad-plugin/skip-message-check

« back to all changes in this revision

Viewing changes to jlp/jenkinsutils.py

  • Committer: Francis Ginther
  • Date: 2017-12-17 17:03:40 UTC
  • mfrom: (132.2.1 jlp-3)
  • Revision ID: francis.ginther@canonical.com-20171217170340-ogh1tzlou1g50ewn
Enable support for Jenkins pipeline type jobs
[a=powersj][r=fginther]

Pipeline jobs do not have downstream projects and currently, this
code causes a KeyError. By capturing this, it allows pipeline jobs to
get executed by the plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
571
571
def get_downstream_projects(jenkins, job_url):
572
572
    data = jenkins.get_json_data(job_url + '/')
573
573
    downstream_projects = []
574
 
    for project in data['downstreamProjects']:
575
 
        downstream_projects.append(project['name'])
 
574
 
 
575
    try:
 
576
        for project in data['downstreamProjects']:
 
577
            downstream_projects.append(project['name'])
 
578
    except KeyError:
 
579
        logger.debug('No downstream projects.')
 
580
 
576
581
    return downstream_projects
577
582
 
578
583