0

i have a jenkins JSON API that gives me a list of all jobs in jenkins

https://<jenkins-url>/api/json?tree=jobs[name]

this works fine in the web browser but when i use this with the curl command in the unix CLI this gives me no output.

curl -u user:password -s -k "https://<jenkins-url>/api/json?tree=jobs[name]"

what am i doing wrong here??

poobear
  • 63
  • 11

1 Answers1

0

Thanks for your question. Try below method. Instead of using plain credentials, you can try using other auth methods. Example Session cookie. You can find your session cookie in the browser cookies section.

curl 'http://<Jenkins server>/jenkins/api/json?pretty=true' \
-H 'Connection: keep-alive' \
-H 'Cache-Control: max-age=0' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36' \
-H 'DNT: 1' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Accept-Encoding: gzip, deflate' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
-H 'Cookie: JSESSIONID=<Session ID>; screenResolution=1280x800' --compressed
arun m
  • 26
  • 6