1

I'm trying to access jenkins (v2.177) API using curl. For instance, I try to get the lastbuild number as follows :

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

Insted of giving me a json, I get a "302 Found" with Content-Length egal to zero ! :

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

Any idea why I don't get the JSON ?

Peter
  • 11
  • 2

1 Answers1

0

Okay ...

I had to specify the branch like that :

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

Now it works

Peter
  • 11
  • 2