尝试访问/ lastBuild / api / json时,jenkins响应“找到HTTP / 1.1 302”

时间:2019-05-14 16:27:52

标签: jenkins curl jenkins-api

我正在尝试使用curl访问jenkins(v2.177)API。例如,我尝试获取lastbuild编号,如下所示:

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

出于给我提供json的考虑,我得到了“ 302 Found”,内容长度egal为零! :

`*   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吗?

1 个答案:

答案 0 :(得分:0)

好吧...

我必须像这样指定分支:

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

现在可以使用

相关问题