python-3.x - 通过 Jenkins 连接到远程 API 时 Python 请求抛出连接错误
问题描述
我正在运行一个在远程主机上调用 API 的 python 脚本。虽然这在本地运行良好,但当我从 Jenkins 作为作业运行此脚本时它会失败。它无法连接到远程主机。
我打算自动化这个过程,因此想在 Jenkins 上运行它。我尝试将证书导入 Jenkins 中的 keytool,认为这是某种证书问题,但看起来 ping 本身无法访问远程主机。
url = https://remotehost:remoteport/api
payload = {
some prams to filter request
}
response = requests.get(url, params=payload,auth=HTTPBasicAuth(USER, PASS ))
构建失败并出现以下错误:
requests.exceptions.ConnectionError:
HTTPConnectionPool(host='remotehost', port=remoteport):
Max retries exceeded with url: /api/params
(Caused by NewConnectionError('<urllib3.connection.HTTPConnection
object at 0x7fc010cb8dd8>: Failed to establish a new connection:
[Errno 110] Connection timed out',))
Build step 'Execute shell' marked build as failure
我不确定这是否会在 Jenkins 中进行更改,因为它在本地运行良好?如果是,任何关于我应该在哪里进行设置的指针?
解决方案
推荐阅读
- php - 如何在 Laravel 中重定向后设置选择值
- parsing - 如何在 Prolog 中创建高阶 DCG 解析器?
- c# - RuntimeMiddleware 目标数组不够长 错误
- python - 错误:没有找到 tensorflow==1.7.1 的匹配分布(来自 unityagents)
- java - 如何检查设备上使用的语言?
- image - Pandoc:在导出到 docx 时将样式应用于所有图像?
- python - 为什么我的输入重复多次?
- json - 需要在提交前检查 Input.Toggle 的真值吗?
- c++ - 复制算法的范围库实现
- html - 如何更改特定表格行的表格边框折叠属性?