Skip to content

Commit 876678a

Browse files
yanksyoonlechat
authored andcommitted
fix: jenkinsapi crashing jenkins_is_unavaiable
1 parent 231cea3 commit 876678a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

jenkinsapi/jenkins.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,15 @@ def _wait_for_reboot(self) -> None:
550550
def __jenkins_is_unavailable(self):
551551
while True:
552552
try:
553-
self.requester.get_and_confirm_status(
554-
self.baseurl, valid=[503, 500]
553+
res = self.requester.get_and_confirm_status(
554+
self.baseurl, valid=[503, 500, 200]
555555
)
556+
# If there is a running job in Jenkins, the system message will
557+
# pop up but the Jenkins instance will return 200
558+
if res.status_code == 200 and "Jenkins is going to shut down" in \
559+
str(res.content, encoding="utf-8"):
560+
time.sleep(1)
561+
continue
556562
return True
557563
except ConnectionError:
558564
# This is also a possibility while Jenkins is restarting

0 commit comments

Comments
 (0)