在Jenkinsfile中将当前分支中的git文件导入列表(windows)

时间:2017-07-12 00:46:32

标签: windows git jenkins groovy

我正在使用声明性管道,并希望获得在工作分支中添加/删除/修改的文件列表。我想把它变成后续条件的groovy列表变量。

环境 - 目前在windows slave上使用git。

1 个答案:

答案 0 :(得分:1)

https://support.cloudbees.com/hc/en-us/articles/217630098-How-to-Access-Changelogs-in-a-Pipeline-Job

def changeLogSets = currentBuild.changeSets
   for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
    def entry = entries[j]
    echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}"
    def files = new ArrayList(entry.affectedFiles)
    for (int k = 0; k < files.size(); k++) {
        def file = files[k]
        echo "  ${file.editType.name} ${file.path}"
    }
}

}