It seems more appropriate to update the request object instead. With your
patch, you'll ignore added headers(including the crumb).
To prevent this, just change the request instanciation for the delete_build
call (wipeout_job_workspace has the same call so it fixes that as well):
diff --git a/jenkins/__init__.py b/jenkins/__init__.py
index 620ce14..0691f2a 100755
--- a/jenkins/__init__.py
+++ b/jenkins/__init__.py
@@ -1469,7 +1469,7 @@ class Jenkins(object):
"""
folder_url, short_name = self._get_job_folder(name)
self.jenkins_open(requests.Request('POST',
- self._build_url(DELETE_BUILD, locals()), b''))
+ self._build_url(DELETE_BUILD, locals())))
def wipeout_job_workspace(self, name):
"""Wipe out workspace for given Jenkins job.
@@ -1479,7 +1479,7 @@ class Jenkins(object):
folder_url, short_name = self._get_job_folder(name)
self.jenkins_open(requests.Request('POST',
self._build_url(WIPEOUT_JOB_WORKSPACE,
- locals()), b''))
+ locals())))
def get_running_builds(self):
'''Return list of running builds.
--
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/1781381
Title:
Cannot delete build using delete_build
Status in Python Jenkins:
New
Bug description:
Requirement already up-to-date: python-jenkins in
.XXXXXXX/venv/lib/python3.6/site-packages (1.0.2)
In line 357 of __init__.py (function maybe_add_crumb) the code fails on
req.headers[self.crumb['crumbRequestField']] = self.crumb['crumb']
at this point i have a value for self.crumb and req.headers is b''
the error i get is "bytes' object does not support item assignment"
trace
File "XXXXXX.py", line 9, in <module>
j.delete_build(r"Whale Watchers/Project Whale Watcher QA - Grouped", k)
File "XXXXXX/venv/lib/python3.6/site-packages/jenkins/__init__.py", line
1354, in delete_build
self._build_url(DELETE_BUILD, locals()), b''))
File "XXXXXX/venv/lib/python3.6/site-packages/jenkins/__init__.py", line
540, in jenkins_open
return self.jenkins_request(req, add_crumb, resolve_auth).text
File "XXXXXX/venv/lib/python3.6/site-packages/jenkins/__init__.py", line
556, in jenkins_request
self.maybe_add_crumb(req)
File "XXXXXX/venv/lib/python3.6/site-packages/jenkins/__init__.py", line
357, in maybe_add_crumb
req.headers[self.crumb['crumbRequestField']] = self.crumb['crumb']
TypeError: 'bytes' object does not support item assignment
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1781381/+subscriptions
--
Mailing list: https://launchpad.net/~python-jenkins-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~python-jenkins-developers
More help : https://help.launchpad.net/ListHelp