Advertisement
GrueMaster

Untitled

May 28th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #!/usr/bin/env groovy
  2.  
  3. def call() {
  4. echo 'Checking c++ tidy output'
  5. def tidyStages
  6. def success = true
  7. sh "mkdir ${WORKSPACE}/tidyLogs"
  8. tidyStages = prepTidyStages()
  9. parallel(tidyStages)
  10. def tidyLogs = sh (script: "find ${WORKSPACE}tidyLogs -type f -size +1", returnStdout: true).split()
  11. for (tLog in tidylogs) {
  12. sh (script: "cat ${WORKSPACE}/tidyLogs\u002F\u0024${tLog} >> ${WORKSPACE}/clang-tidy.log")
  13. success = false
  14. } else {
  15. sh "rm ${WORKSPACE}/tidyLogs/${tLog}"
  16. }
  17. }
  18. if (success) {
  19. } else {
  20. recordIssues qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]], tools: [clangTidy(pattern: 'clang-tidy.log')]
  21. archiveArtifacts "${WORKSPACE}/tidyLogs/*.log"
  22. error('Failed clang-tidy')
  23. }
  24. }
  25.  
  26. def prepTidyStages() {
  27. def tidyStages = [:]
  28. // Get a list of changes based on master branch
  29. def fileList = sh(script: 'git diff-tree --no-commit-id --diff-filter=d --name-only -r `git merge-base refs/remotes/origin/master HEAD` HEAD',
  30. returnStdout: true).split()
  31. for (chgFile in fileList) {
  32. fileName = sh(script: "basename ${chgFile}", returnStdout: true).trim()
  33. filePath = sh(script: "realpath ${chgFile}", returnStdout: true).trim()
  34. tidyStages.put(fileName, prepOneTidyStage(fileName, filePath))
  35. }
  36. return tidyStages
  37. }
  38.  
  39. def prepOneTidyStage(String fName, String fPath) {
  40. return {
  41. sh "clang-tidy -p ${WORKSPACE}/build ${fPath} | tee ${WORKSPACE}/tidyLogs/${fName}.log"
  42. }
  43. }
  44.  
  45.  
  46.  
  47. Output:
  48. ERROR: Failed cppTidy
  49. org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
  50. /var/jenkins_home/jobs/test-parallel/builds/73/libs/Megh_Pipes/vars/cppTidy.groovy: 15: expecting '}', found 'else' @ line 15, column 11.
  51. } else {
  52. ^
  53.  
  54. 1 error
  55.  
  56. at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
  57. at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
  58. at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
  59. at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132)
  60. .
  61. .
  62. .
  63. .
  64. .
  65. (30 lines of Java crash dumps are useless here)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement