Interview Prep/Jenkins/Architecture, executors & JENKINS_HOME

How do you call the Jenkins REST API?

BeginnerConceptArchitecture, executors & JENKINS_HOME
Answer

Append /api/json (or /api/xml) to almost any URL, and use the tree parameter to limit fields. POST requests need an API token (which bypasses the CSRF crumb) or a crumb with a session.

curl -s -u alice:$TOKEN "https://jenkins/job/app/job/main/lastBuild/api/json?tree=result,number,duration"
curl -X POST -u alice:$TOKEN "https://jenkins/job/deploy/buildWithParameters?ENV=dev"
curl -s -u alice:$TOKEN "https://jenkins/job/app/job/main/42/consoleText"
All Jenkins questions Roadmap: Jenkins

More on Architecture, executors & JENKINS_HOME