notification.groovy 981 B

1234567891011121314151617181920212223242526272829
  1. def processString(String content) {
  2. return content
  3. }
  4. @NonCPS
  5. def collectChangeInfo() {
  6. // 配置文件扩展名正则匹配
  7. def configFilePatterns = ~/.*[\\/]*[^\\/]*\.(yaml|yml|ini|groovy)$/
  8. // 存储最后一个符合条件的变更
  9. def lastCodeChange = ""
  10. def changeLogSets = currentBuild.changeSets
  11. changeLogSets.each { changeSet ->
  12. changeSet.items.each { entry ->
  13. // 检查是否有非配置文件的变更
  14. def isCodeChange = entry.affectedFiles.any { file ->
  15. !(file.path ==~ configFilePatterns)
  16. }
  17. if (isCodeChange) {
  18. lastCodeChange += "Commit ${entry.commitId.substring(0, 8)} by ${entry.author} Info"
  19. lastCodeChange += "${entry.msg}\n"
  20. }
  21. }
  22. }
  23. return lastCodeChange ? lastCodeChange.trim() : "No valid code changes found."
  24. }
  25. return this