Skip to content

query on how to handle HTTPError: 401 Client Error: Invalid password/token for user #861

@mlsxdx

Description

@mlsxdx
ISSUE TYPE
  • How to handle requests.exceptions.HTTPError: 401 Client Error
Jenkinsapi VERSION

0.3.11

Jenkins VERSION

2.164.2

SUMMARY

Recently my jenkinsapi complains HTTPError: 401 Client Error: Invalid password/token for user:
I want to know how to add this exception handling in my program.

EXPECTED RESULTS

When this HTTPError: 401 Client Error occurs, retry it(call build.get_data() again)

ACTUAL RESULTS

Just want to get some input on how to implement such in my program.
Currently I am using block_until_complete(delay=300) in build.py to poll the build status.

build.block_until_complete(delay=300)
USEFUL INFORMATION

I want to have similar function to override is_running(self) in build.py which can handle HTTPError: 401

ERROR:jenkinsapi.jenkinsbase:Failed request at http://jen/job/huracan_check_in/4730/api/python with params: {'depth': 1, 'tree': 'building'} building
Traceback (most recent call last):
  File "/home/tma/TRY/TryPython/TryAutoPush/jks_bp.py", line 121, in <module>
    build.block_until_complete(delay=300)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 417, in block_until_complete
    while self.is_running():
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 399, in is_running
    data = self.poll(tree='building')
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/jenkinsbase.py", line 60, in poll
    data = self._poll(tree=tree)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/build.py", line 63, in _poll
    return self.get_data(url, params={'depth': self.depth}, tree=tree)
  File "/home/tma/.local/lib/python3.9/site-packages/jenkinsapi/jenkinsbase.py", line 84, in get_data
    response.raise_for_status()
  File "/home/tma/.local/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Invalid password/token for user: tma for url: http://jen/job/huracan_check_in/4730/api/python?depth=1&tree=building

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions