[英]Running (system/Jenkins) groovy script on slave while accessing build variable
I'm trying to run a groovy script which is updating the build.description
during the execution while running a process on a slave node. 我正在尝试运行一个Groovy脚本,该
build.description
在执行过程中在从属节点上运行进程时更新build.description
。
My problem is that a "system groovy script' executes only on the master node and 'Jenkins groovy scripts' run on slave nodes but have no access to the build
variable. 我的问题是,“系统常规脚本”仅在主节点上执行,“詹金斯常规脚本”在从属节点上运行,但是无法访问
build
变量。
I have a script similar to this one: 我有一个与此脚本类似的脚本:
import hudson.model.*
// works on slave node
def param = args[0]
// works on master node
//def param = build.getEnvironment(listener).get('Params')
def ws = new File(".").absolutePath
def myCommand = ws + "\\Something.exe " + param
def proc = myCommand.execute();
// Cannot use on slave
build.description = "Running executable..."
int exitVal = proc.waitFor();
// Cannot use on slave
build.description = "Executable finished"
Is there a way to modify the build variable on a "Jenkins Groovy Script" which runs on a slave? 有没有办法在从属服务器上运行的“ Jenkins Groovy脚本”上修改构建变量?
Thanks in advance! 提前致谢!
No. 没有。
Jenkins pipeline exposes more control on such things. Jenkins管道对此类事情公开了更多控制权。
Following is from script we have. 以下是我们拥有的脚本。
nodeexpression
could a node name. nodeexpression
可以是节点名称。
node(nodeexpression) {
println "env :"
echo sh(script: 'env|sort', returnStdout: true)
currentBuild.displayName = "branch ${BRANCH}:${MAIL_TO}"
currentBuild.description = "${BRANCH}:${MAIL_TO} : message -> ${MESSAGE}"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.