Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- def call() {
- echo 'Checking c++ tidy output'
- def tidyStages
- def success = true
- sh "mkdir ${WORKSPACE}/tidyLogs"
- tidyStages = prepTidyStages()
- parallel(tidyStages)
- def tidyLogs = sh (script: "find ${WORKSPACE}tidyLogs -type f -size +1", returnStdout: true).split()
- for (tLog in tidylogs) {
- sh (script: "cat ${WORKSPACE}/tidyLogs\u002F\u0024${tLog} >> ${WORKSPACE}/clang-tidy.log")
- success = false
- } else {
- sh "rm ${WORKSPACE}/tidyLogs/${tLog}"
- }
- }
- if (success) {
- } else {
- recordIssues qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]], tools: [clangTidy(pattern: 'clang-tidy.log')]
- archiveArtifacts "${WORKSPACE}/tidyLogs/*.log"
- error('Failed clang-tidy')
- }
- }
- def prepTidyStages() {
- def tidyStages = [:]
- // Get a list of changes based on master branch
- 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',
- returnStdout: true).split()
- for (chgFile in fileList) {
- fileName = sh(script: "basename ${chgFile}", returnStdout: true).trim()
- filePath = sh(script: "realpath ${chgFile}", returnStdout: true).trim()
- tidyStages.put(fileName, prepOneTidyStage(fileName, filePath))
- }
- return tidyStages
- }
- def prepOneTidyStage(String fName, String fPath) {
- return {
- sh "clang-tidy -p ${WORKSPACE}/build ${fPath} | tee ${WORKSPACE}/tidyLogs/${fName}.log"
- }
- }
- Output:
- ERROR: Failed cppTidy
- org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
- /var/jenkins_home/jobs/test-parallel/builds/73/libs/Megh_Pipes/vars/cppTidy.groovy: 15: expecting '}', found 'else' @ line 15, column 11.
- } else {
- ^
- 1 error
- at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
- at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
- at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
- at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132)
- .
- .
- .
- .
- .
- (30 lines of Java crash dumps are useless here)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement