
A Jenkins Admin can execute groovy scripts remotely by sending an HTTP POST request to /script/ url or /scriptText/.
curl example via bash
[code]
curl -d “script=<your_script_here>” https://jenkins/script
# or to get output as a plain text result (no HTML)
curl -d “script=<your_script_here>” https://jenkins/scriptText
[/code]
curl submitting groovy file via bash
[code]
curl –data-urlencode “script=$(< ./somescript.groovy)” https://jenkins/scriptText
[/code]
curl submitting groovy file providing username and password via bash
[code]
curl –user ‘username:password’ –data-urlencode “script=$(< ./somescript.groovy)” https://jenkins/scriptText
[/code]
Jenkins CLI offers the possibility to execute groovy scripts remotely using groovy command or execute groovy interactivelly via groovysh.
[code]
java -jar jenkins-cli.jar -noCertificateCheck -s https://10.0.0.91/ groovy disableEnableJobsMatchingPattern.groovy jobPattern=build_git_auto disableOrEnable=disable –username 12345 –password banana
[/code]
Reference
https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console













I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND