简体   繁体   中英

Jenkins/Hudson Groovy Script Console: Flexibility

I really like being able to run Groovy scripts in Hudson (or Jenkins, but I use Hudson).

For example, see my question In Groovy, how do I get the list of parameter names for a given job? Hudson parameter names question][1]

The thing is, now I'd like use these Groovy scripts like a keyboard macro or utility. I want to be visiting one of my jobs, hit the special keystroke, and voila, the Groovy script is run. I leave it as an exercise for myself to pick up parameters from environment of current job.

Does anybody out there do this sort of thing, and if so, what strategy has been useful. So far, all I know how to do is bring up the script console, pasted in my code, edit the variable containing the name of the Hudson job, and hit "run". Kinda klunky. Suggestions appreciated.

You can use jenkins Remote access method to do this. The Jenkins wiki describes how to use Remote access :

User can execute groovy scripts remotely sending post request to /script/ url or /scriptText/ to have response returned without the html wrapping.

 $ curl -d "script=<your_script_here>" http://jenkins/script $ # or $ curl -d "script=<your_script_here>" http://jenkins/scriptText 

Also, Jenkins CLI offers the possibility to execute groovy scripts remotely using groovy command or execute groovy interactivelly via groovysh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM