Merge "Fix error thrown in presence of placeholder tasks"

This commit is contained in:
Jenkins 2017-03-02 14:54:45 +00:00 committed by Gerrit Code Review
commit 331bfa36df
2 changed files with 38 additions and 1 deletions

View File

@ -1146,7 +1146,7 @@ class Jenkins(object):
raise
for executor in info['executors']:
executable = executor['currentExecutable']
if executable:
if executable and 'PlaceholderTask' not in executable.get('_class', ''):
executor_number = executor['number']
build_number = executable['number']
url = executable['url']

View File

@ -417,3 +417,40 @@ class JenkinsListRunningBuildsTest(JenkinsTestBase):
builds = self.j.get_running_builds()
# Should treat the slave as not running any builds
self.assertEqual([], builds)
@patch.object(jenkins.Jenkins, 'get_node_info')
@patch.object(jenkins.Jenkins, 'get_nodes')
def test_placeholder_task_in_queue(self, nodes_mock, node_info_mock):
nodes_to_return = [{
'name': "foo-slave", 'offline': False
}]
nodes_mock.return_value = nodes_to_return
node_info_to_return = {
"executors": [
{
"currentExecutable": None,
"currentWorkUnit": None,
"idle": True,
"likelyStuck": False,
"number": 1,
"progress": -1
},
{
'currentExecutable': {
'_class': (
'org.jenkinsci.plugins.workflow.support.steps.'
'ExecutorStepExecution$PlaceholderTask$'
'PlaceholderExecutable'
)
},
'currentWorkUnit': {},
'idle': False,
'likelyStuck': False,
'number': 1,
'progress': 0
}
],
}
node_info_mock.return_value = node_info_to_return
builds = self.j.get_running_builds()
self.assertEqual([], builds)