Allow adding extra HTTP headers to Jenkins requests
In some network setups Jenkins may be hidden behind complex reverse proxy setups that require additional custom headers to be set on each request in order to pass them trough Allow providing such headers using JENKINS_API_EXTRA_HEADERS environment variable Change-Id: If071c5c707f916ba5f4f2c371ec600b7476bf723
This commit is contained in:
@@ -321,6 +321,14 @@ class Jenkins(object):
|
||||
self.timeout = timeout
|
||||
self._session = WrappedSession()
|
||||
|
||||
extra_headers = os.environ.get("JENKINS_API_EXTRA_HEADERS", "")
|
||||
if extra_headers:
|
||||
logging.warning("JENKINS_API_EXTRA_HEADERS adds these HTTP headers: %s", extra_headers.split("\n"))
|
||||
for token in extra_headers.split("\n"):
|
||||
if ":" in token:
|
||||
header, value = token.split(":", 1)
|
||||
self._session.headers[header] = value.strip()
|
||||
|
||||
if os.getenv('PYTHONHTTPSVERIFY', '1') == '0':
|
||||
logging.debug('PYTHONHTTPSVERIFY=0 detected so we will '
|
||||
'disable requests library SSL verification to keep '
|
||||
|
||||
Reference in New Issue
Block a user