How to get list of changed files since last build in Jenkins/Hudson

后端 未结 11 2018
时光取名叫无心
时光取名叫无心 2020-11-28 09:35

I have set up Jenkins, but I would like to find out what files were added/changed between the current build and the previous build. I\'d like to run some long running tests

11条回答
  •  悲&欢浪女
    2020-11-28 10:28

    I tried to add that to comments but code in comments is no way:

    Just want to prettify code from heroin's answer:

    def changedFiles = []
    def changeLogSets = currentBuild.changeSets
    for (entries in changeLogSets) {
        for (entry in entries) {
            for (file in entry.affectedFiles) {
                echo "Found changed file: ${file.path}"
                changedFiles += "${file.path}"
            }
        }
    }
    

    Keep in mind for some cases git plugin returns empty changeSet, like:

    • First run in newly created branch
    • 'Build now' button build

    Refer to https://issues.jenkins-ci.org/browse/JENKINS-26354 for more details.

提交回复
热议问题