【问题标题】:jenkins responds "HTTP/1.1 302 Found" when trying to access /lastBuild/api/jsonjenkins 在尝试访问 /lastBuild/api/json 时响应“HTTP/1.1 302 Found”
【发布时间】:2019-05-14 16:27:52
【问题描述】:

我正在尝试使用 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 吗?

【问题讨论】:

    标签: jenkins curl jenkins-api


    【解决方案1】:

    好的……

    我必须这样指定分支:

    curl -v -u user:pass http://myjenkins:port/job/myjob/job/mybranch/lastBuild/api/json
    

    现在可以了

    【讨论】:

      猜你喜欢
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      • 2017-02-27
      • 2016-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多