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

后端 未结 11 2021
时光取名叫无心
时光取名叫无心 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:31

    With Jenkins pipelines (pipeline supporting APIs plugin 2.2 or above), this solution is working for me:

    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]
        def files = new ArrayList(entry.affectedFiles)
        for (int k = 0; k < files.size(); k++) {
          def file = files[k]
          println file.path
        }
      }
    }
    

    See How to access changelogs in a pipeline job.

提交回复
热议问题