From e09b9e780eb477cfb1a08d5ae504d540a6f4d2ef Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 22 Aug 2019 18:53:12 +0100 Subject: [PATCH 1/5] GIS-1621 - Do static analysis --- staticanalysis/ccm.groovy | 110 ++++++++++++++++++++++++++ staticanalysis/cpd.groovy | 139 +++++++++++++++++++++++++++++++++ staticanalysis/cppcheck.groovy | 104 ++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 staticanalysis/ccm.groovy create mode 100644 staticanalysis/cpd.groovy create mode 100644 staticanalysis/cppcheck.groovy diff --git a/staticanalysis/ccm.groovy b/staticanalysis/ccm.groovy new file mode 100644 index 0000000..290c897 --- /dev/null +++ b/staticanalysis/ccm.groovy @@ -0,0 +1,110 @@ +pipeline { + agent { label "${AGENT_LABEL}" } + stages { + stage('Initial setup') { + steps { + script { + meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) + } + } + } + stage('Checkout dependencies') { + steps { + script { + configurationhelper = autobuilder.configurationhelper() + + PYTHONURL = 'git@hydra:tools/python.git' + PYTHONBRANCH = 'origin/3.6.3_windows' + PYTHONDIR = "${WORKSPACE}/python" + configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR) + env.PYTHON = "${PYTHONDIR}/ver/python.exe" + + CCMURL = 'git@hydra:tools/ccm.git' + CCMBRANCH = 'origin/master' + CCMDIR = "${WORKSPACE}/ccm" + configurationhelper.gitCheckoutAndRegister(meta, 'ccm', CCMURL, CCMBRANCH, CCMDIR) + CCM = "${CCMDIR}/bin/CCM.exe" + } + } + } + stage('Checkout source') { + steps { + script { + SOURCEREVISION = "${SOURCE_REVISION}" + SOURCEDIR = "${WORKSPACE}/source" + configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false) + SOURCE_PATH = "${SOURCEDIR}" + env.SRC = "${SOURCE_PATH}/${SOURCE_OFFSET_PATH}" + } + } + } + stage("Clean exports") { + steps { + script { + STATICANALYSIS = 'staticanalysis' + cleanfolders = [ + STATICANALYSIS, + ] + cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy") + cleaner.clean(cleanfolders) + } + } + } + stage('Generating version info') { + steps { + script { + version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy") + version.generate(meta, SOURCE_REVISION, SOURCE_PATH, BASEBUILDNUMBER) + } + } + } + stage('Static analysis') { + steps { + script { + def CCMOLDER = "${STATICANALYSIS}/ccm" + dir(CCMOLDER) { + bat """ + "${CCM}" "${SRC}" /xml /nummetrics=100 > ccm.xml + """ + } + recordIssues(tools: [ + ccm(pattern: "**/ccm.xml", reportEncoding: 'UTF-8'), + ]) + } + } + } + stage('Classifying publishable artifacts') { + steps { + script { + def publishable = [ + ] + publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy") + publishutils.generatelist(meta, publishable) + } + } + } + stage('Archiving artifacts') { + steps { + script { + ArrayList itemsForRelease = ["${STATICANALYSIS}/**"] + def artifactlist = meta.generateartifacts(itemsForRelease) + archiveArtifacts "${artifactlist}" + } + } + } + } + post { + always { + echo 'Post-build' + } + failure { + echo 'Failed build' + } + unstable { + echo 'Unstable build' + } + success { + echo 'Succeeded build' + } + } +} diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy new file mode 100644 index 0000000..18cdb43 --- /dev/null +++ b/staticanalysis/cpd.groovy @@ -0,0 +1,139 @@ +pipeline { + agent { label "${AGENT_LABEL}" } + stages { + stage('Initial setup') { + steps { + script { + meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) + } + } + } + stage('Checkout dependencies') { + steps { + script { + configurationhelper = autobuilder.configurationhelper() + + PYTHONURL = 'git@hydra:tools/python.git' + if (isUnix()) { + PYTHONBRANCH = 'origin/3.6.3_linux' + } else { + PYTHONBRANCH = 'origin/3.6.3_windows' + } + PYTHONDIR = "${WORKSPACE}/python" + configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR) + env.PYTHON = "${PYTHONDIR}/ver/python.exe" + + JAVAURL = 'git@hydra:tools/openjdk.git' + if (isUnix()) { + JAVABRANCH = 'origin/openjdk-11.0.2_linux-x64_bin' + } else { + JAVABRANCH = 'origin/openjdk-11.0.2_windows-x64_bin' + } + JAVADIR = "${WORKSPACE}/java" + configurationhelper.gitCheckoutAndRegister(meta, 'java', JAVAURL, JAVABRANCH, JAVADIR) + JAVA = "${JAVADIR}/ver/bin" + if (isUnix()) { + env.PATH = JAVA + ':' + PATH + } else { + env.PATH = JAVA + ';' + PATH + } + + PPDURL = 'git@hydra:tools/pmd.git' + PPDBRANCH = 'origin/master' + PPDDIR = "${WORKSPACE}/ppd" + configurationhelper.gitCheckoutAndRegister(meta, 'ppd', PPDURL, PPDBRANCH, PPDDIR) + PPD = "${PPDDIR}/bin" + } + } + } + stage('Checkout source') { + steps { + script { + SOURCEREVISION = "${SOURCE_REVISION}" + SOURCEDIR = "${WORKSPACE}/source" + configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false) + SOURCE_PATH = "${SOURCEDIR}" + env.SRC = "${SOURCE_PATH}/${SOURCE_OFFSET_PATH}" + } + } + } + stage("Clean exports") { + steps { + script { + STATICANALYSIS = 'staticanalysis' + cleanfolders = [ + STATICANALYSIS, + ] + cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy") + cleaner.clean(cleanfolders) + } + } + } + stage('Generating version info') { + steps { + script { + version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy") + version.generate(meta, SOURCE_REVISION, SOURCE_PATH, BASEBUILDNUMBER) + } + } + } + stage('Static analysis') { + steps { + script { + def PPDFOLDER = "${STATICANALYSIS}/ppd" + dir(PPDFOLDER) { + if (isUnix()) { + sh """#!/bin/bash + set -e + + export PMD_JAVA_OPTS=-Xmx16384m + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml > cpd.xml + """ + } else { + bat """ + set PMD_JAVA_OPTS=-Xmx2048m + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml > cpd.xml + """ + } + } + recordIssues(tools: [ + cpd(pattern: "**/cpd.xml", reportEncoding: 'UTF-8'), + ]) + } + } + } + stage('Classifying publishable artifacts') { + steps { + script { + def publishable = [ + ] + publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy") + publishutils.generatelist(meta, publishable) + } + } + } + stage('Archiving artifacts') { + steps { + script { + ArrayList itemsForRelease = ["${STATICANALYSIS}/**"] + def artifactlist = meta.generateartifacts(itemsForRelease) + archiveArtifacts "${artifactlist}" + } + } + } + } + post { + always { + echo 'Post-build' + } + failure { + echo 'Failed build' + } + unstable { + echo 'Unstable build' + } + success { + echo 'Succeeded build' + } + } +} diff --git a/staticanalysis/cppcheck.groovy b/staticanalysis/cppcheck.groovy new file mode 100644 index 0000000..b3b997e --- /dev/null +++ b/staticanalysis/cppcheck.groovy @@ -0,0 +1,104 @@ +pipeline { + agent { label "${AGENT_LABEL}" } + stages { + stage('Initial setup') { + steps { + script { + meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) + } + } + } + stage('Checkout dependencies') { + steps { + script { + configurationhelper = autobuilder.configurationhelper() + + PYTHONURL = 'git@hydra:tools/python.git' + PYTHONBRANCH = 'origin/3.6.3_windows' + PYTHONDIR = "${WORKSPACE}/python" + configurationhelper.gitCheckoutAndRegister(meta, 'python', PYTHONURL, PYTHONBRANCH, PYTHONDIR) + env.PYTHON = "${PYTHONDIR}/ver/python.exe" + } + } + } + stage('Checkout source') { + steps { + script { + SOURCEREVISION = "${SOURCE_REVISION}" + SOURCEDIR = "${WORKSPACE}/source" + configurationhelper.gitCheckoutAndRegister(meta, 'source', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false) + SOURCE_PATH = "${SOURCEDIR}" + env.SRC = "${SOURCE_PATH}/${SOURCE_OFFSET_PATH}" + } + } + } + stage("Clean exports") { + steps { + script { + STATICANALYSIS = 'staticanalysis' + cleanfolders = [ + STATICANALYSIS, + ] + cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy") + cleaner.clean(cleanfolders) + } + } + } + stage('Generating version info') { + steps { + script { + version = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy") + version.generate(meta, SOURCE_REVISION, SOURCE_PATH, BASEBUILDNUMBER) + } + } + } + stage('Static analysis') { + steps { + script { + def CPPCHECKFOLDER = "${STATICANALYSIS}/cppcheck" + dir(CPPCHECKFOLDER) { + bat """ + "${CPPCHECK}" --xml --xml-version=2 "${SRC}" 2> cppcheck.xml + """ + } + recordIssues(tools: [ + cppCheck(pattern: "**/cppcheck.xml", reportEncoding: 'UTF-8'), + ]) + } + } + } + stage('Classifying publishable artifacts') { + steps { + script { + def publishable = [ + ] + publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy") + publishutils.generatelist(meta, publishable) + } + } + } + stage('Archiving artifacts') { + steps { + script { + ArrayList itemsForRelease = ["${STATICANALYSIS}/**"] + def artifactlist = meta.generateartifacts(itemsForRelease) + archiveArtifacts "${artifactlist}" + } + } + } + } + post { + always { + echo 'Post-build' + } + failure { + echo 'Failed build' + } + unstable { + echo 'Unstable build' + } + success { + echo 'Succeeded build' + } + } +} From a87215229efa2b30d451217216c3d93fc8dcf534 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 22 Aug 2019 19:43:30 +0100 Subject: [PATCH 2/5] Update static analysis --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 18cdb43..d1a227f 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -84,7 +84,7 @@ pipeline { dir(PPDFOLDER) { if (isUnix()) { sh """#!/bin/bash - set -e + set -xe export PMD_JAVA_OPTS=-Xmx16384m "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml > cpd.xml From 3ad05866a5c50d26e2b1c786bf19211d7b8ff230 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 22 Aug 2019 19:50:44 +0100 Subject: [PATCH 3/5] Update static analysis --- staticanalysis/cpd.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index d1a227f..9277ca9 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -87,12 +87,12 @@ pipeline { set -xe export PMD_JAVA_OPTS=-Xmx16384m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnValidation false > cpd.xml """ } else { bat """ set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml > cpd.xml + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnValidation false > cpd.xml """ } } From 34fd570e60cda2b21df321f6dc8a60bde5581720 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 22 Aug 2019 19:52:55 +0100 Subject: [PATCH 4/5] Update static analysis --- staticanalysis/cpd.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 9277ca9..b114ee8 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -87,12 +87,12 @@ pipeline { set -xe export PMD_JAVA_OPTS=-Xmx16384m - "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnValidation false > cpd.xml + "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml """ } else { bat """ set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnValidation false > cpd.xml + "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml """ } } From d4aea83255d773ff9b59a8df08bc0b0ac9f1391f Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Thu, 22 Aug 2019 19:56:19 +0100 Subject: [PATCH 5/5] Update static analysis --- staticanalysis/cpd.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index b114ee8..4691eb4 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -84,7 +84,7 @@ pipeline { dir(PPDFOLDER) { if (isUnix()) { sh """#!/bin/bash - set -xe + set -e export PMD_JAVA_OPTS=-Xmx16384m "${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml