如何将$ {CHANGES}传递给下游工作? [英] How to pass ${CHANGES} to downstream job?

查看:145
本文介绍了如何将$ {CHANGES}传递给下游工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有上游工作,对SVN进行轮询以进行更改. 如果检测到更改,则开始构建. 构建完成后,上游项目将调用下游项目进行测试.我正在使用触发器参数化版本".

I have upstream job that polls SVN for changes. If changes are detected, the build is started. After the build, the upstream project calls downstream project to run test. I'm using "Trigger Parameterized Build".

我希望下游项目能够发送包含导致构建/测试的测试结果和SVN更改的电子邮件.但是问题是,如果我在下游使用$ {CHANGES}变量,它似乎是空的.

I want that downstream project will be able to send an email with test results and SVN changes that cause to the build/test. But the problem is that if I'm using ${CHANGES} variable in downstream it appear to be empty.

如何将$ {CHANGES}从上游项目传递到下游项目?

How can I pass ${CHANGES} from upstream project to downstream project?

推荐答案

您可以使用groovy脚本获取更改集或所需的值:

You can get the change set or the values you need with groovy script:

def jenkins = Jenkins.getInstance()
def job = jenkins.getItem(jobName)
def bld = job.getBuildByNumber(buildNumber)
def changeSet = bld.getChangeSet()

然后,它取决于您使用哪个scm插件,例如,可以使用git-plugin:

then it dependents on which scm plugin you use, for example with git-plugin you can:

获取每个更改的修订版本:

get the revision of each change:

changeSet.each{
    println it.getRevision()
}

获取每次更改的消息:

changeSet.each{
    println it.getMsg()
}

获取受影响的路径:

changeSet.each{
   println it.getAffectedPaths()
}

获取作者姓名:

changeSet.each{
    println it.getAuthorName()
}

还有更多动作

这篇关于如何将$ {CHANGES}传递给下游工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆