def get_all_jobs()

in src/plugins/scanners/jenkins.py [0:0]


def get_all_jobs(KibbleBit, source, joblist, creds):
    real_jobs = []
    building = 0
    for job in joblist:
        # Is this a job folder?
        jclass = job.get('_class')
        if jclass in ['jenkins.branch.OrganizationFolder', 'org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject']:
            KibbleBit.pprint("%s is a jobs folder, expanding..." % job['name'])
            csURL = '%s/job/%s' % (source['sourceURL'], urllib.parse.quote(job['name'].replace('/', '%2F')))
            try:
                child_jobs = plugins.utils.jsonapi.get("%s/api/json?tree=jobs[name,color]&depth=1" % csURL,
                                                       auth=creds)
                csource = dict(source)
                csource['sourceURL'] = csURL
                if not csource.get('folder'):
                    csource['folder'] = job['name']
                else:
                    csource['folder'] += '-' + job['name']
                cjobs, cbuilding = get_all_jobs(KibbleBit, csource, child_jobs.get('jobs', []), creds)
                building += cbuilding
                for cjob in cjobs:
                    real_jobs.append(cjob)
            except:
                KibbleBit.pprint("Couldn't get child jobs, bailing")
                print("%s/api/json?tree=jobs[name,color]&depth=1" % csURL)
        # Or standard job?
        else:
            # Is it building?
            if 'anime' in job.get('color', ''):  # a running job will have foo_anime as color
                building += 1
            job['fullURL'] = '%s/job/%s' % (source['sourceURL'], urllib.parse.quote(job['name'].replace('/', '%2F')))
            job['folder'] = source.get('folder')
            real_jobs.append(job)
    return real_jobs, building