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
- Apache Lucene Query Example - April 8, 2024
- Google Cloud: Step by Step Tutorials for setting up Multi-cluster Ingress (MCI) - April 7, 2024
- What is Multi-cluster Ingress (MCI) - April 7, 2024