From ea7faf51c7b64eabd33e959d5557c1db05eca45c Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:03:00 +0100 Subject: [PATCH 01/20] Show environment --- staticanalysis/cpd.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 2bd12d9..05c00fb 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -5,6 +5,9 @@ pipeline { steps { script { meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) + sh """#!/bin/bash + env + """ } } } From caf5ddbe8c06b44f4eee4f32c883685a4832b6b4 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:18:32 +0100 Subject: [PATCH 02/20] Handle path exclusions --- staticanalysis/cpd.groovy | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 05c00fb..7d4ccb7 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -85,17 +85,21 @@ pipeline { script { def PPDFOLDER = "${STATICANALYSIS}/ppd" dir(PPDFOLDER) { + def EXCLUDE_PARAM = '' + if (EXCLUDE_PATHS) { + EXCLUDE_PARAM = """--exclude "%EXCLUDE_PATHS%" """ + } if (isUnix()) { sh """#!/bin/bash set -e export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml %EXCLUDE_PARAM% --failOnViolation false > cpd.xml """ } else { bat """ set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml %EXCLUDE_PARAM% --failOnViolation false > cpd.xml """ } } From 4ec0d0e1b6ba2fb63b06b7fcd82b0d9169d57b2b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:28:14 +0100 Subject: [PATCH 03/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 7d4ccb7..49dde7c 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -85,7 +85,7 @@ pipeline { script { def PPDFOLDER = "${STATICANALYSIS}/ppd" dir(PPDFOLDER) { - def EXCLUDE_PARAM = '' + EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { EXCLUDE_PARAM = """--exclude "%EXCLUDE_PATHS%" """ } From 1d18f769e533383118c73ce1c0c12e420badd9ab Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:30:21 +0100 Subject: [PATCH 04/20] Handle path exclusions --- staticanalysis/cpd.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 49dde7c..60dad56 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -89,6 +89,7 @@ pipeline { if (EXCLUDE_PATHS) { EXCLUDE_PARAM = """--exclude "%EXCLUDE_PATHS%" """ } + echo "EXCLUDE_PARAM=%EXCLUDE_PARAM%" if (isUnix()) { sh """#!/bin/bash set -e From 7aa4e9299e41bab76093557b3faefb08ee17231b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:31:48 +0100 Subject: [PATCH 05/20] Handle path exclusions --- staticanalysis/cpd.groovy | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 60dad56..b4fb1ad 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -85,22 +85,21 @@ pipeline { script { def PPDFOLDER = "${STATICANALYSIS}/ppd" dir(PPDFOLDER) { - EXCLUDE_PARAM = '' + def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = """--exclude "%EXCLUDE_PATHS%" """ + EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS}" """ } - echo "EXCLUDE_PARAM=%EXCLUDE_PARAM%" if (isUnix()) { sh """#!/bin/bash set -e export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml %EXCLUDE_PARAM% --failOnViolation false > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml """ } else { bat """ set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml %EXCLUDE_PARAM% --failOnViolation false > cpd.xml + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml """ } } From d75fd3ca51627df7e38861842a453f19bf14b860 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:38:38 +0100 Subject: [PATCH 06/20] Handle path exclusions --- staticanalysis/cpd.groovy | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index b4fb1ad..6731c94 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -89,18 +89,20 @@ pipeline { if (EXCLUDE_PATHS) { EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS}" """ } - if (isUnix()) { - sh """#!/bin/bash - set -e - - export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ - } else { - bat """ - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ + dir(SRC) { + if (isUnix()) { + sh """#!/bin/bash + set -e + + export PMD_JAVA_OPTS=-Xmx65536m + "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ + } else { + bat """ + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ + } } } recordIssues(tools: [ From c82bbc6b4752b6c1582eaee6549c3f2888085572 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:41:30 +0100 Subject: [PATCH 07/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 6731c94..127db9f 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -92,7 +92,7 @@ pipeline { dir(SRC) { if (isUnix()) { sh """#!/bin/bash - set -e + set -ev export PMD_JAVA_OPTS=-Xmx65536m "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml From 9c9e0999fcd8ecfef74d3e6a38e755938f93314f Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 10:59:05 +0100 Subject: [PATCH 08/20] Handle path exclusions --- staticanalysis/cpd.groovy | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 127db9f..649ba89 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -87,22 +87,26 @@ pipeline { dir(PPDFOLDER) { def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS}" """ - } - dir(SRC) { - if (isUnix()) { - sh """#!/bin/bash - set -ev - - export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ - } else { - bat """ - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ + EXCLUDE_PARAM = '--exclude "' + def exclude_path_list = EXCLUDE_PATHS.split() + for (exclude_path in exclude_path_list) { + EXCLUDE_PARAM += "${WORKSPACE}/${exclude_path.trim()}," } + EXCLUDE_PARAM += '"' + } + if (isUnix()) { + sh """#!/bin/bash + set -ev + + export PMD_JAVA_OPTS=-Xmx65536m + echo "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ + } else { + bat """ + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ } } recordIssues(tools: [ From ec496bb55743616fae5a6b7a3f40cde9525a2e79 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 11:11:17 +0100 Subject: [PATCH 09/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 649ba89..d4956b1 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -90,7 +90,7 @@ pipeline { EXCLUDE_PARAM = '--exclude "' def exclude_path_list = EXCLUDE_PATHS.split() for (exclude_path in exclude_path_list) { - EXCLUDE_PARAM += "${WORKSPACE}/${exclude_path.trim()}," + EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()}," } EXCLUDE_PARAM += '"' } From 0890fb01b3123b9475987dea37f760123ddeba8c Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 11:16:10 +0100 Subject: [PATCH 10/20] Handle path exclusions --- staticanalysis/cpd.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index d4956b1..6d717a5 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -56,7 +56,10 @@ pipeline { SOURCEDIR = "${WORKSPACE}/source" configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false) SOURCE_PATH = "${SOURCEDIR}" - env.SRC = "${SOURCE_PATH}/${SOURCE_OFFSET_PATH}" + SRC = "${SOURCE_PATH}" + if (SOURCE_OFFSET_PATH) { + SRC += "/${SOURCE_OFFSET_PATH}" + } } } } From 35018f9956528b297d05579d2db8a26a2520c1fb Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 11:18:18 +0100 Subject: [PATCH 11/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 6d717a5..e20b0de 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -91,7 +91,7 @@ pipeline { def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { EXCLUDE_PARAM = '--exclude "' - def exclude_path_list = EXCLUDE_PATHS.split() + def exclude_path_list = EXCLUDE_PATHS.split(',') for (exclude_path in exclude_path_list) { EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()}," } From 7a590ecad57b4cd3700960759053fa73337efed5 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 11:37:38 +0100 Subject: [PATCH 12/20] Handle path exclusions --- staticanalysis/cpd.groovy | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index e20b0de..07f922e 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -97,19 +97,21 @@ pipeline { } EXCLUDE_PARAM += '"' } - if (isUnix()) { - sh """#!/bin/bash - set -ev + dir(SRC) { + if (isUnix()) { + sh """#!/bin/bash + set -ev - export PMD_JAVA_OPTS=-Xmx65536m - echo "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ - } else { - bat """ - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ + export PMD_JAVA_OPTS=-Xmx65536m + echo "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ + } else { + bat """ + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml + """ + } } } recordIssues(tools: [ From 29cfbbf9d651f5d511eef37b92d203251feec579 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:05:45 +0100 Subject: [PATCH 13/20] Handle path exclusions --- staticanalysis/cpd.groovy | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 07f922e..5f357ce 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -1,13 +1,10 @@ pipeline { - agent { label "${AGENT_LABEL}" } + agent { label AGENT_LABEL } stages { stage('Initial setup') { steps { script { meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) - sh """#!/bin/bash - env - """ } } } @@ -103,7 +100,6 @@ pipeline { set -ev export PMD_JAVA_OPTS=-Xmx65536m - echo "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml """ } else { From 562c1cbc21f1f3ac246a06ff2771644458eae6c0 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:29:19 +0100 Subject: [PATCH 14/20] Handle path exclusions --- staticanalysis/cpd.groovy | 41 +++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 5f357ce..0bc5c12 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -84,30 +84,25 @@ pipeline { steps { script { def PPDFOLDER = "${STATICANALYSIS}/ppd" - dir(PPDFOLDER) { - def EXCLUDE_PARAM = '' - if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = '--exclude "' - def exclude_path_list = EXCLUDE_PATHS.split(',') - for (exclude_path in exclude_path_list) { - EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()}," - } - EXCLUDE_PARAM += '"' - } - dir(SRC) { - if (isUnix()) { - sh """#!/bin/bash - set -ev + def EXCLUDE_PARAM = '' + if (EXCLUDE_PATHS) { + EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim}"""" + } + dir(SRC) { + if (isUnix()) { + sh """#!/bin/bash + set -ev - export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ - } else { - bat """ - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > cpd.xml - """ - } + mkdir "${PPDFOLDER}" + export PMD_JAVA_OPTS=-Xmx65536m + "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + """ + } else { + bat """ + mkdir "${PPDFOLDER}" + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + """ } } recordIssues(tools: [ From 0514270ca56dfacf90740100ed70fa03be537ed7 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:31:18 +0100 Subject: [PATCH 15/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 0bc5c12..90c0efa 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -86,7 +86,7 @@ pipeline { def PPDFOLDER = "${STATICANALYSIS}/ppd" def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim}"""" + EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim}" """ } dir(SRC) { if (isUnix()) { From df2bd2f03760bf060d0d9c4092c5c202bfba9633 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:32:48 +0100 Subject: [PATCH 16/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 90c0efa..6651870 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -86,7 +86,7 @@ pipeline { def PPDFOLDER = "${STATICANALYSIS}/ppd" def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim}" """ + EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim()}" """ } dir(SRC) { if (isUnix()) { From 0114f4e16b3e98afea231f430e4b81fc684bd484 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:34:45 +0100 Subject: [PATCH 17/20] Handle path exclusions --- staticanalysis/cpd.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 6651870..9e21374 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -93,13 +93,13 @@ pipeline { sh """#!/bin/bash set -ev - mkdir "${PPDFOLDER}" + mkdir -p "${PPDFOLDER}" export PMD_JAVA_OPTS=-Xmx65536m "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" """ } else { bat """ - mkdir "${PPDFOLDER}" + mkdir -p "${PPDFOLDER}" set PMD_JAVA_OPTS=-Xmx2048m "${PPD}/cpd.bat" --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" """ From 21bc371542991ea4c4964115b3e5dc8105c27bec Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:43:41 +0100 Subject: [PATCH 18/20] Handle path exclusions --- staticanalysis/cpd.groovy | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 9e21374..01cdc64 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -86,24 +86,27 @@ pipeline { def PPDFOLDER = "${STATICANALYSIS}/ppd" def EXCLUDE_PARAM = '' if (EXCLUDE_PATHS) { - EXCLUDE_PARAM = """--exclude "${EXCLUDE_PATHS.trim()}" """ - } - dir(SRC) { - if (isUnix()) { - sh """#!/bin/bash - set -ev - - mkdir -p "${PPDFOLDER}" - export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" - """ - } else { - bat """ - mkdir -p "${PPDFOLDER}" - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files . --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" - """ + EXCLUDE_PARAM = '--exclude "' + def exclude_path_list = EXCLUDE_PATHS.split(',') + for (exclude_path in exclude_path_list) { + EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()}," } + EXCLUDE_PARAM += '"' + } + if (isUnix()) { + sh """#!/bin/bash + set -ev + + mkdir -p "${PPDFOLDER}" + export PMD_JAVA_OPTS=-Xmx65536m"${SRC}""${SRC}" + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + """ + } else { + bat """ + mkdir -p "${PPDFOLDER}" + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + """ } recordIssues(tools: [ cpd(pattern: "**/cpd.xml", reportEncoding: 'UTF-8'), From edb44517747f02f2054bdcaaff4bb0cec729458b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:47:06 +0100 Subject: [PATCH 19/20] Handle path exclusions --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 01cdc64..d4bf093 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -98,7 +98,7 @@ pipeline { set -ev mkdir -p "${PPDFOLDER}" - export PMD_JAVA_OPTS=-Xmx65536m"${SRC}""${SRC}" + export PMD_JAVA_OPTS=-Xmx65536m "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" """ } else { From be93f030970c724c0cdeb48764e7ea8a34947071 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 4 Oct 2020 12:52:31 +0100 Subject: [PATCH 20/20] Handle path exclusions --- staticanalysis/cpd.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index d4bf093..6f3a33f 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -99,13 +99,13 @@ pipeline { mkdir -p "${PPDFOLDER}" export PMD_JAVA_OPTS=-Xmx65536m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml" """ } else { bat """ mkdir -p "${PPDFOLDER}" set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}cpd.xml" + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml" """ } recordIssues(tools: [