简体   繁体   English

jenkins 中执行 groovy 脚本和执行系统 ​​groovy 脚本的区别?

[英]Difference between execute groovy script and the execute system groovy script in jenkins?

Can anyone explain the different between the execute groovy script and the execute system groovy script in jenkins?谁能解释一下 jenkins 中执行 groovy 脚本和执行系统 ​​groovy 脚本之间的区别? And how to call the script to slave using execute system groovy script.以及如何使用execute system groovy脚本将脚本调用到slave。

To execute a groovy script on the slave machine, you should use groovy plugin要在从机上执行 groovy 脚本,您应该使用groovy 插件

Quote引用

The plain "Groovy Script" is run in a forked JVM, on the slave where the build is run.普通的“Groovy 脚本”在分叉的 JVM 中运行,在运行构建的从站上。 It's the basically the same as running the "groovy" command and pass in the script.它与运行“groovy”命令并传入脚本基本相同。

First part of your question is answered in the same page您的问题的第一部分在同一页面中得到回答

The system groovy script, OTOH, runs inside the Hudson master's JVM.系统 groovy 脚本 OTOH 在 Hudson 主机的 JVM 内运行。 Thus it will have access to all the internal objects of Hudson, so you can use this to alter the state of Hudson.因此它将可以访问 Hudson 的所有内部对象,因此您可以使用它来更改 Hudson 的状态。 It is similar to the Jenkins Script Console functionality.它类似于 Jenkins 脚本控制台功能。

Another point on system Groovy scripts to be aware of.关于系统 Groovy 脚本的另一点需要注意。 While the documentation says that it always runs on the Jenkins master, I've found through painful means that it isn't true if it's in a job that is triggered by another job.虽然文档说它总是在 Jenkins master 上运行,但我通过痛苦的方式发现,如果它在由另一个作业触发的作业中,则情况并非如此。 In that case, make sure you specifically restrict it to run on the master or bad things will happen.在这种情况下,请确保您明确限制它在主服务器上运行,否则会发生不好的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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