我有一个jenkins JSON API,它为我提供了jenkins中所有工作的列表
https://<jenkins-url>/api/json?tree=jobs[name]
这在网络浏览器中运行良好,但是当我在unix CLI中使用curl命令时,这给了我没有输出。
curl -u user:password -s -k "https://<jenkins-url>/api/json?tree=jobs[name]"
我在这里做错了什么?
答案 0 :(得分:0)
感谢您的提问。尝试以下方法。您可以尝试使用其他身份验证方法,而不是使用普通凭据。示例会话cookie。 您可以在浏览器cookie部分找到您的会话cookie。
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