如何在Jenkins的changeSet中获得修订/ commitID

时间:2019-01-24 09:49:17

标签: jenkins

我正在尝试在Jenkins的changeSet中获取commitID /修订。这是我的代码:

我得到的commitId为空,但是构建完成后,我可以从“更改”页面下的摘要中获取修订。

def project = hudson.model.Hudson.instance.getItem(project_name)
def buildnum = some_number

build =  project.getBuildByNumber(buildnum)

def upstreamBuilds = build.getUpstreamBuilds()

upstreamBuilds.each() { key, value ->
  def prj = key;
  def num = value;
  build = prj.getBuildByNumber(num);
}

def changeSet = build.changeSet
if(changeSet != null) {
  def hadChanges = false
  changeSet.each() { cs ->
    hadChanges = true
    println(cs.author)
    println(cs.commitId)
    println(cs.msgAnnotated)
  }
}

如何从构建的changeSet中获取正确的commitId?

0 个答案:

没有答案