简体   繁体   English

Jenkins / Hudson Groovy脚本控制台:灵活性

[英]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.

相关问题 哈德森* .groovy在詹金斯找不到 - hudson*.groovy not found in jenkins Jenkins / Hudson CLI API使用Groovy获取脚本正在运行的节点 - Jenkins/Hudson CLI API get the node that the script is running on using Groovy 使用Jenkins脚本控制台并查看Groovy输出 - Using Jenkins script console and seeing the Groovy output 外部groovy脚本给出错误:groovy.lang.MissingPropertyException:无此类属性:hudson。 在詹金斯中使用时 - external groovy script is giving error : groovy.lang.MissingPropertyException: No such property: hudson. while using in Jenkins 使用groovy脚本失败hudson构建 - Fail hudson build with groovy script 使用构建后的Groovy脚本获取构建持续时间(Jenkins / Hudson) - Get build duration using post-build Groovy script (Jenkins/Hudson) 如何在Jenkins奴隶的脚本控制台中使用groovy运行python命令? - How to run python commands using groovy in Jenkins slaves' Script Console? 可以针对Jenkins脚本控制台优化此MultiBranch Pipeline Groovy代码片段吗? - Can this MultiBranch Pipeline Groovy Snippet for the Jenkins Script Console beoptimized? 从 Jenkins Groovy Script-Console 编写文件 - Write a File from Jenkins Groovy Script-Console 如何从jenkins控制台使用groovy脚本捕获第二个字符串 - How to capture second string using groovy script from jenkins console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM