python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00648
[Bug 1922580] [NEW] stop_build causes an HTTPError and JenkinsException
Public bug reported:
If I call stop_build() on a running build, the build will stop but I get
two exceptions.
```
client = jenkins.Jenkins('jenkins.example.com', 'systemuser', 'somepass')
client.build_job('citest-long-idle')
# wait for build to start
client.get_running_builds()
[{'name': 'citest-long-idle',
'number': 8,
'url': 'https://jenkins.example.com/job/citest-long-idle/8/',
'node': 'LinuxWorker-0fc32e96',
'executor': 4}]
client.stop_build('citest-long-idle', 8)
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_request(self, req, add_crumb, resolve_auth)
575 return self._response_handler(
--> 576 self._request(req))
577
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in _response_handler(self, response)
535 # raise exceptions if occurred
--> 536 response.raise_for_status()
537
/usr/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
942 if http_error_msg:
--> 943 raise HTTPError(http_error_msg, response=self)
944
HTTPError: 403 Client Error: Forbidden for url:
https://jenkins.example.com/job/citest-long-idle/8/
During handling of the above exception, another exception occurred:
JenkinsException Traceback (most recent call last)
<ipython-input-70-f7841b332a7b> in <module>
----> 1 client.stop_build('citest-long-idle', 8)
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in stop_build(self, name, number)
1403 folder_url, short_name = self._get_job_folder(name)
1404 self.jenkins_open(requests.Request(
-> 1405 'POST', self._build_url(STOP_BUILD, locals())
1406 ))
1407
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_open(self, req, add_crumb, resolve_auth)
555 :returns: ``str``
556 '''
--> 557 return self.jenkins_request(req, add_crumb, resolve_auth).text
558
559 def jenkins_request(self, req, add_crumb=True, resolve_auth=True):
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_request(self, req, add_crumb, resolve_auth)
585 if e.response.text:
586 msg += '\n' + e.response.text
--> 587 raise JenkinsException(msg)
588 elif e.response.status_code == 404:
589 raise NotFoundException('Requested item could not be found')
JenkinsException: Error in request. Possibly authentication failed [403]: Forbidden
<html><head><meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2Fjob%2Fcitest-long-idle%2F8%2F'/><script>window.location.replace('/securityRealm/commenceLogin?from=%2Fjob%2Fcitest-long-idle%2F8%2F');</script></head><body style='background-color:white; color:white;'>
Authentication required
<!--
-->
</body></html>
```
Jenkins Version: 2.285
python-jenkins: 1.7.0
python: 3.7.10
** 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/1922580
Title:
stop_build causes an HTTPError and JenkinsException
Status in Python Jenkins:
New
Bug description:
If I call stop_build() on a running build, the build will stop but I
get two exceptions.
```
client = jenkins.Jenkins('jenkins.example.com', 'systemuser', 'somepass')
client.build_job('citest-long-idle')
# wait for build to start
client.get_running_builds()
[{'name': 'citest-long-idle',
'number': 8,
'url': 'https://jenkins.example.com/job/citest-long-idle/8/',
'node': 'LinuxWorker-0fc32e96',
'executor': 4}]
client.stop_build('citest-long-idle', 8)
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_request(self, req, add_crumb, resolve_auth)
575 return self._response_handler(
--> 576 self._request(req))
577
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in _response_handler(self, response)
535 # raise exceptions if occurred
--> 536 response.raise_for_status()
537
/usr/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
942 if http_error_msg:
--> 943 raise HTTPError(http_error_msg, response=self)
944
HTTPError: 403 Client Error: Forbidden for url:
https://jenkins.example.com/job/citest-long-idle/8/
During handling of the above exception, another exception occurred:
JenkinsException Traceback (most recent call last)
<ipython-input-70-f7841b332a7b> in <module>
----> 1 client.stop_build('citest-long-idle', 8)
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in stop_build(self, name, number)
1403 folder_url, short_name = self._get_job_folder(name)
1404 self.jenkins_open(requests.Request(
-> 1405 'POST', self._build_url(STOP_BUILD, locals())
1406 ))
1407
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_open(self, req, add_crumb, resolve_auth)
555 :returns: ``str``
556 '''
--> 557 return self.jenkins_request(req, add_crumb, resolve_auth).text
558
559 def jenkins_request(self, req, add_crumb=True, resolve_auth=True):
~/.local/lib/python3.7/site-packages/jenkins/__init__.py in jenkins_request(self, req, add_crumb, resolve_auth)
585 if e.response.text:
586 msg += '\n' + e.response.text
--> 587 raise JenkinsException(msg)
588 elif e.response.status_code == 404:
589 raise NotFoundException('Requested item could not be found')
JenkinsException: Error in request. Possibly authentication failed [403]: Forbidden
<html><head><meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2Fjob%2Fcitest-long-idle%2F8%2F'/><script>window.location.replace('/securityRealm/commenceLogin?from=%2Fjob%2Fcitest-long-idle%2F8%2F');</script></head><body style='background-color:white; color:white;'>
Authentication required
<!--
-->
</body></html>
```
Jenkins Version: 2.285
python-jenkins: 1.7.0
python: 3.7.10
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1922580/+subscriptions