How to get the changes since the last successful build in jenkins pipeline?

后端 未结 6 547
忘了有多久
忘了有多久 2020-12-09 10:44

Anyone have a Jenkins Pipeline script that can stuff all the changes since the previous successful build in a variable? I\'m using git and a multibranch pipeline job.

6条回答
  •  隐瞒了意图╮
    2020-12-09 11:17

    This is what I've used:

    def listFilesForBuild(build) {
      def files = []
      currentBuild.changeSets.each {
        it.items.each {
          it.affectedFiles.each {
            files << it.path
          }
        }
      }
      files
    }
    
    def filesSinceLastPass() {
      def files = []
      def build = currentBuild
      while(build.result != 'SUCCESS') {
        files += listFilesForBuild(build)
        build = build.getPreviousBuild()
      }
      return files.unique()
    }
    
    def files = filesSinceLastPass()
    

提交回复
热议问题