🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to execute grovvy script remotely on Jenkins server?

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

 

 

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
reCaptcha Error: grecaptcha is not defined

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x