jenkinsapi
jenkinsapi copied to clipboard
QueueItem::block_until_building blocks forever if the queue item gets cancelled
ISSUE TYPE
- Bug Report
Jenkinsapi version: 0.3.9
Jenkins version: 2.204.1
SUMMARY
QueueItem::block_until_building
blocks forever if the queue item gets cancelled on Jenkins.
EXPECTED RESULTS
QueueItem::block_until_building
should raise an exception if the queue item gets cancelled on Jenkins.
ACTUAL RESULTS
QueueItem::block_until_building
did not raise an exception, but kept trying to check if the build started.
USEFUL INFORMATION
How to reproduce:
1- Trigger a build with delay and create a QueueItem like so: queue_item = QueueItem(resp.headers["Location"], jenkins)
2- Execute queue_item.block_until_building()
3- Cancel the queue item on Jenkins
4- block_until_building
blocks forever
QueueItem::block_until_building
calls QueueItem::get_build
, which calls QueueItem::get_build_number
. This method raises NotBuiltYet
even when the queue item has been cancelled. In this case, the method catches TypeError and raises the NotBuiltYet
.
Traceback (most recent call last):
File "<PATH_TO_PROJECT>\venv\lib\site-packages\jenkinsapi\queue.py", line 172, in get_build_number
return self._data['executable']['number']
TypeError: 'NoneType' object is not subscriptable
queue.py line 170-174:
def get_build_number(self):
try:
return self._data['executable']['number']
except (KeyError, TypeError):
raise NotBuiltYet()