If you do not understand why this fails, run a debugger in strace / dtruss , for example.
$ strace -fs1000 -e trace=network java -jar jenkins-cli.jar -s http://localhost:8080/ help
If you have:
HTTP / 1.1 403 There was no doubt about the request.
then you need to either provide the crumb in the request or disable CSRF Protection .
Using the Jenkins CLI it still does not work when the rabbit agent is on, so you can use curl . For example (replace localhost with your Jenkins address):
- Pay attention to the user API token (
/user/USER/configure ). Get your baby:
CRUMB=$(curl -s 'http://USER: TOKEN@localhost :8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
Calling some command (for example, a list of tasks):
curl -H $CRUMB http://USER: TOKEN@localhost :8080/api/json
Related: Jenkins REST API Create Job
source share