在slave上运行(system/Jenkins)groovy脚本,同时访问构建变量

agxfikkp  于 6个月前  发布在  Jenkins
关注(0)|答案(1)|浏览(56)

我正在尝试运行一个groovy脚本,它在从节点上运行一个进程时,在执行过程中更新build.description
我的问题是,“系统groovy脚本”只在主节点上执行,而“Jenkins groovy脚本”在从节点上运行,但无法访问build变量。
我有一个类似的脚本:

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"

字符串
有没有一种方法可以修改在从站上运行的“Jenkins Groovy Script”上的构建变量?

92dk7w1h

92dk7w1h1#


Jenkins pipeline在这些事情上提供了更多的控制。
下面是从脚本中我们有. 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}"
  }

字符串

相关问题