speed up job existence test by fetching less informations
speed up job existence test by fetching less informations

The job_exists() methods rely on an API call that cause Jenkins to LazyLoad the
build history. Whenever a job has a huge build history, that would be awfully
slow.  The API let you fetch only a subset of the information you need by using
the 'tree' parameter, by requesting only the name of the job, we ensure the
server is only going to do a very simple operation.

It is then only a matter of checking the job name returned the API is equal to
the one requested, that validates the job exists and is accessible.

Tested out on a dev setup with a job having a million builds:

import jenkins
from pprint import pprint

j = jenkins.Jenkins('https://localhost:8080/')

for job_name in ['huge-history', 'Idonotexist']:
    print "Getting job name of %s" % job_name
    pprint(j.get_job_name(job_name))
    print "Does it exist?"
    pprint(j.job_exists(job_name))

Output:

Getting job name of huge-history
u'huge-history'
Does it exist?
True
Getting job name of Idonotexist
None
Does it exist?
None

msabramo/python-jenkins,jeblair/python-jenkins,stackforge/python-jenkins,yershalom/python-jenkins,Puneeth-n/python-jenkins,klmitch/python-jenkins,minddistrict/python-jenkins