jenkins - jenkins 在尝试访问 /lastBuild/api/json 时响应“HTTP/1.1 302 Found”
问题描述
我正在尝试使用 curl 访问 jenkins (v2.177) API。例如,我尝试获取 lastbuild 编号,如下所示:
curl -v -u user:pass http://myjenkins:port/job/myjob/lastBuild/api/json
为了给我一个json,我得到一个“302 Found”,内容长度等于零!:
`* Trying 11.90.1.9...
* TCP_NODELAY set
* Connected to 11.90.1.9 (11.90.1.9) port 8484 (#0)
* Server auth using Basic with user 'user7'
> GET /job/myjob/lastBuild HTTP/1.1
> Host: 11.90.1.9:8484
> Authorization: Basic dGVzdGl.../blc2Y...
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Tue, 14 May 2019 13:01:12 GMT
< X-Content-Type-Options: nosniff
< Location: http://11.90.1.9:8484/job/myjob/
< Content-Length: 0
< Server: Jetty(9.4.z-SNAPSHOT)
<
* Connection #0 to host 11.90.1.9 left intact`
知道为什么我没有得到 JSON 吗?
解决方案
好的 ...
我不得不像这样指定分支:
curl -v -u user:pass http://myjenkins:port/job/myjob/job/mybranch/lastBuild/api/json
现在它可以工作了
推荐阅读
- git - github如何让我自己的仓库可以被任何人下载
- python - 如何使用 Pandas groupby 在组上添加顺序计数器列?
- javascript - 如何检查并列出 if 语句中的所有错误条件 - JavaScript?
- python - 拆分列时如何跳过 NaN 值
- curl - Curl 命令错误:返回类似于 javascript 的内容
- reactjs - useState 不会异步工作(React)
- c++ - 确定最大利润算法 C++
- node.js - 如何使用 Google Drive V3 创建文件夹?
- reactjs - 为什么我的 React 应用程序不能使用我的 Apache .htaccess 文件来防止 404?
- google-cloud-data-fusion - 访问 BigQuery 时出错 [无法获取有关 BigQuery 表的详细信息:BigQuery 的访问被拒绝]