
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 Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals