[英]Jenkins/Hudson Groovy Script Console: Flexibility
I really like being able to run Groovy scripts in Hudson (or Jenkins, but I use Hudson). 我非常喜欢能够在Hudson(或Jenkins,但我使用Hudson)中运行Groovy脚本。
For example, see my question In Groovy, how do I get the list of parameter names for a given job? 例如,请参阅我的问题。 在Groovy中,如何获取给定作业的参数名称列表? Hudson parameter names question][1] 哈德逊参数名称问题] [1]
The thing is, now I'd like use these Groovy scripts like a keyboard macro or utility. 问题是,现在我想使用这些Groovy脚本,例如键盘宏或实用程序。 I want to be visiting one of my jobs, hit the special keystroke, and voila, the Groovy script is run. 我想去找我的工作之一,按一下特殊的键,然后,运行Groovy脚本。 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". 到目前为止,我所要做的就是打开脚本控制台,粘贴到我的代码中,编辑包含Hudson作业名称的变量,然后单击“运行”。 Kinda klunky. 有点儿笨拙。 Suggestions appreciated. 建议表示赞赏。
You can use jenkins Remote access
method to do this. 您可以使用jenkins Remote access
方法来执行此操作。 The Jenkins wiki describes how to use Remote access
: Jenkins Wiki描述了如何使用Remote access
:
User can execute groovy scripts remotely sending post request to
/script/
url or/scriptText/
to have response returned without the html wrapping. 用户可以执行groovy脚本,远程将发布请求发送到/script/
url或/scriptText/
以返回响应,而无需进行html包装。$ 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. 此外,Jenkins CLI还提供了使用groovy命令远程执行groovy脚本或通过groovysh交互式执行groovy的可能性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.