I want to use some Jenkins features that are not available at REST API, Could I execute they as I do in the console script but through REST API?


  • CloudBees Jenkins Enterprise > 1.596.1.1
  • Jenkins LTS > 1.596.1
  • Jenkins > 1.600


Jenkins supports scripting with the Groovy language. You can get a scripting console by opening in a browser the URL /script of your Jenkins instance. (i.e: http://localhost:8080/script)

The advantage of the Groovy language is that those Groovy scripts are executed within Jenkins and have access to everything (config, plugins, jobs, etc).

To automate the execution of this script, you can save it to a file (let’s say /tmp/script.groovy) and run the following curl command:

curl -d "script=$(cat /tmp/script.groovy)" -v --user username:ApiToken http://localhost:8080/scriptText
curl -d "script=println 'this script works'" -v --user username:ApiToken http://localhost:8080/scriptText
Have more questions? Submit a request


Please sign in to leave a comment.