Skip to main content

Execute Groovy script in Jenkins remotely



  • Praveen Haldipur

    Wrote a groovy script works from the web console but fails with parsing errors when used from REST API. Why the diff?

    it fails on '&' i have embedded in some HTML that I am adding to summary action for a build.


  • Praveen Haldipur

    Need to use curl --data-urlencode when using REST API. That worked!

  • Ed Mason

    When I try this on Windows with a multi-line script I find that it only executes the first line.  Any ideas?

    script test.groovy

    println 'starting script'

    >curl.exe -d "script=$(type /temp/test.groovy)" -v --user <my_userid> https://<my_jenkins_server>/scriptText


    * upload completely sent off: 129 out of 129 bytes
    < HTTP/1.1 200 OK
    < Date: Wed, 27 Nov 2019 15:32:57 GMT
    < Server: Jetty(9.4.z-SNAPSHOT)
    < X-Content-Type-Options: nosniff
    < Content-Type: text/plain;charset=utf-8
    < Content-Length: 16
    starting script
    * Connection #0 to host <my_jenkins_server> left intact





Please sign in to leave a comment.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.