get_running_builds returns error due to missing array.

Bug #1682629 reported by jlakin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python Jenkins
New
Undecided
Unassigned

Bug Description

In Jenkins-2.32.3, when running get_running_builds(), if an executor has no executeables, it removes the array and replaces it with a string "None", resulting in errors.

            for executor in info['executors']:
                executable = executor['currentExecutable']
                if executable and 'PlaceholderTask' not in executable.get('_class', ''):
                    executor_number = executor['number']
                    build_number = executable['number']
                    url = executable['url']
                    m = re.search(r'/job/([^/]+)/.*', urlparse(url).path)
                    job_name = m.group(1)
                    builds.append({'name': job_name,
                                   'number': build_number,
                                   'url': url,
                                   'node': node_name,
                                   'executor': executor_number})
        return builds

>>> info_master = server.get_node_info('(master)', depth=2)

As seen below, the currentExecutable key in the second executor (number: 1) is not an array, but rather a string "None", causing the build.append to fail and return an error.

>>> info_master['executors']
[{u'likelyStuck': False, u'number': 0, u'idle': False, u'currentWorkUnit': {}, u'progress': 92, u'currentExecutable': {u'_class': u'org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask$PlaceholderExecutable'}}, {u'likelyStuck': False, u'number': 1, u'idle': True, u'currentWorkUnit': None, u'progress': -1, u'currentExecutable': None}

ERROR:
>>> server.get_running_builds
<bound method Jenkins.get_running_builds of <jenkins.Jenkins object at 0x7f5965989c90>>
>>> server.get_running_builds90
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Jenkins' object has no attribute 'get_running_builds90'
>>> server.get_running_builds()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/jenkins/__init__.py", line 1151, in get_running_builds
    build_number = executable['number']
KeyError: 'number'
>>>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.