Public bug reported: def get_job_info(self, name, depth=0, fetch_all_builds=False): '''Get job information dictionary.
:param name: Job name, ``str`` :param depth: JSON depth, ``int`` :param fetch_all_builds: If true, all builds will be retrieved from Jenkins. Otherwise, Jenkins will only return the most recent 100 builds. This comes at the expense of an additional API call which may return significant amounts of data. ``bool`` :returns: dictionary of job information ''' folder_url, short_name = self._get_job_folder(name) try: response = self.jenkins_open(requests.Request( 'GET', self._build_url(JOB_INFO, locals()) )) if response: if fetch_all_builds: return self._add_missing_builds(json.loads(response)) else: return json.loads(response) else: raise JenkinsException('job[%s] does not exist' % name) except (req_exc.HTTPError, NotFoundException): raise JenkinsException('job[%s] does not exist' % name) except ValueError: raise JenkinsException( "Could not parse JSON info for job[%s]" % name) i have some issue by this function. response was "JSON info for job". caused by description fields has some characters. \u200B, unknown escape character, etc. You can solve this problem by changing it as follows. def get_job_info(self, name, depth=0, fetch_all_builds=False): '''Get job information dictionary. :param name: Job name, ``str`` :param depth: JSON depth, ``int`` :param fetch_all_builds: If true, all builds will be retrieved from Jenkins. Otherwise, Jenkins will only return the most recent 100 builds. This comes at the expense of an additional API call which may return significant amounts of data. ``bool`` :returns: dictionary of job information ''' folder_url, short_name = self._get_job_folder(name) try: response = self.jenkins_open(requests.Request( 'GET', self._build_url(JOB_INFO, locals()) )) response = clean_json_string(response) if response: if fetch_all_builds: return self._add_missing_builds(json.loads(response)) else: return json.loads(response) else: raise JenkinsException('job[%s] does not exist' % name) except (req_exc.HTTPError, NotFoundException): raise JenkinsException('job[%s] does not exist' % name) except ValueError: raise JenkinsException( "Could not parse JSON info for job[%s]" % name) def clean_json_string(self, json_str): json_str = re.sub(r'\u200B', ' ', json_str) json_str = re.sub(r'\\[^\x00-\x7F]+', '', json_str) json_str = re.sub(r'[\x00-\x1F\x7F-\x9F]', '', json_str) return json_str ** Affects: python-jenkins Importance: Undecided Status: New -- You received this bug notification because you are a member of Python Jenkins Developers, which is subscribed to Python Jenkins. https://bugs.launchpad.net/bugs/2105473 Title: get_job_info return json load fail Status in Python Jenkins: New Bug description: def get_job_info(self, name, depth=0, fetch_all_builds=False): '''Get job information dictionary. :param name: Job name, ``str`` :param depth: JSON depth, ``int`` :param fetch_all_builds: If true, all builds will be retrieved from Jenkins. Otherwise, Jenkins will only return the most recent 100 builds. This comes at the expense of an additional API call which may return significant amounts of data. ``bool`` :returns: dictionary of job information ''' folder_url, short_name = self._get_job_folder(name) try: response = self.jenkins_open(requests.Request( 'GET', self._build_url(JOB_INFO, locals()) )) if response: if fetch_all_builds: return self._add_missing_builds(json.loads(response)) else: return json.loads(response) else: raise JenkinsException('job[%s] does not exist' % name) except (req_exc.HTTPError, NotFoundException): raise JenkinsException('job[%s] does not exist' % name) except ValueError: raise JenkinsException( "Could not parse JSON info for job[%s]" % name) i have some issue by this function. response was "JSON info for job". caused by description fields has some characters. \u200B, unknown escape character, etc. You can solve this problem by changing it as follows. def get_job_info(self, name, depth=0, fetch_all_builds=False): '''Get job information dictionary. :param name: Job name, ``str`` :param depth: JSON depth, ``int`` :param fetch_all_builds: If true, all builds will be retrieved from Jenkins. Otherwise, Jenkins will only return the most recent 100 builds. This comes at the expense of an additional API call which may return significant amounts of data. ``bool`` :returns: dictionary of job information ''' folder_url, short_name = self._get_job_folder(name) try: response = self.jenkins_open(requests.Request( 'GET', self._build_url(JOB_INFO, locals()) )) response = clean_json_string(response) if response: if fetch_all_builds: return self._add_missing_builds(json.loads(response)) else: return json.loads(response) else: raise JenkinsException('job[%s] does not exist' % name) except (req_exc.HTTPError, NotFoundException): raise JenkinsException('job[%s] does not exist' % name) except ValueError: raise JenkinsException( "Could not parse JSON info for job[%s]" % name) def clean_json_string(self, json_str): json_str = re.sub(r'\u200B', ' ', json_str) json_str = re.sub(r'\\[^\x00-\x7F]+', '', json_str) json_str = re.sub(r'[\x00-\x1F\x7F-\x9F]', '', json_str) return json_str To manage notifications about this bug go to: https://bugs.launchpad.net/python-jenkins/+bug/2105473/+subscriptions -- Mailing list: https://launchpad.net/~python-jenkins-developers Post to : python-jenkins-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~python-jenkins-developers More help : https://help.launchpad.net/ListHelp