diff --git a/checksum/utils.groovy b/checksum/utils.groovy index c2503cd..be7569d 100644 --- a/checksum/utils.groovy +++ b/checksum/utils.groovy @@ -5,6 +5,7 @@ def generatelist(meta, checksummable) { def checksumset = meta.checksuminfo.addChecksumSet(filepath) def files = findFiles(glob: filepath) for (file in files) { + echo "Checksumming: ${file.path}" def sum = sha1(file: file.path).trim() checksumset.addChecksumPair(file.path, sum) } diff --git a/commandline/commandline.groovy b/commandline/commandline.groovy index df99a75..38f80fa 100644 --- a/commandline/commandline.groovy +++ b/commandline/commandline.groovy @@ -2,8 +2,7 @@ String getCommandOutput(String cmd) { if (isUnix()) { return sh(returnStdout: true, script: '#!/bin/sh -e\n' + cmd).trim() } else { - return bat(returnStdout: true, script: """ - @echo off + return powershell(returnStdout: true, script: """ ${cmd} """ ).trim() diff --git a/compile/eclipsebuild/eclipseSTM8build.groovy b/compile/eclipsebuild/eclipseSTM8build.groovy new file mode 100644 index 0000000..2aef386 --- /dev/null +++ b/compile/eclipsebuild/eclipseSTM8build.groovy @@ -0,0 +1,172 @@ +def doDisplayLeftovers() { +} + +def doKillLeftovers() { +} + +def doCheck(checkpathlist, build_variant = "") { + def result = 0 + for (checkpath in checkpathlist) { + echo "Checking file at: ${checkpath}" + script { + echo "Build variant is ${build_variant}" + if (build_variant) { + def srcFile = "${WORKSPACE}\${checkpath}" + def srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}") + // Print out dependencies of the built file + echo "Showing dependencies of ${srcFileExpanded}" + if (srcFileExpanded.endsWith(".elf")) { + result = bat ( script: """ + ${CYGWINDIR}/bin/readelf -hS ${srcFileExpanded} + if errorlevel 1 EXIT /b 1 + """, + returnStatus: true + ) + } + if (result != 0) { + return result + } + } + } + } + return result +} + +def doExport(exportfolder, exportpathlist, partdest = "", build_variant = "") { + def result = 0 + def destFolder = "" + def srcFile = "" + def srcFileExpanded = "" + for (exportpath in exportpathlist) { + echo "Export path at: ${exportpath}" + script { + if (build_variant) { + echo "Build variant is ${build_variant}" + srcFile = "${WORKSPACE}\\${exportpath}" + srcFileExpanded = srcFile.replace("-BUILDVARIANT-", "${build_variant}") + } + else { + echo "No build variant" + srcFileExpanded = "${WORKSPACE}\\${exportpath}" + } + destFolder = "${exportfolder}" + if (partdest) { + destFolder += "\\" + partdest + } + } + def destFolderExpanded = destFolder.replace("-BUILDVARIANT-", "${build_variant}") + dir (destFolderExpanded) { + echo "Copy \"${srcFileExpanded}\" to \"${destFolderExpanded}\"" + result = bat( script: """ + copy "${srcFileExpanded}" "${destFolderExpanded}" + if errorlevel 1 EXIT /b 1 + """, + returnStatus: true + ) + if (result != 0) { + return result + } + } + } + return result +} + +// Import all eclipse projects in a given folder +def doImportProjects(ds5folder, ds5shellcommand, buildcommand, sourcefolder) { + bat """ + "${ds5shellcommand}" ${buildcommand} -no-indexer -importAll "${sourcefolder}" + """ +} + +def doBuildAndExportProject(String ds5folder, String ds5shellcommand, String buildcommand, String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) { + echo "Doing build and export project: ${project} : ${doexport}" + for (build_variant in variants) { + retry(maxprojectbuildretries) { // Eclipse occasionally raises exceptions (rather than the builds failing) + try { + if (toBuild.contains(build_variant)) { + doDisplayLeftovers() + echo "Build command: ${ds5shellcommand} \'${buildcommand} -no-indexer -build ${project}/${build_variant}\'" + timeout(time: 20, unit: 'MINUTES') { + bat """ + "${ds5shellcommand}" ${buildcommand} -no-indexer -build ${project}/${build_variant} + """ + } + result = doCheck(exportpathlist, build_variant) + if (result != 0) { + error "Failed to check files...." + } + echo "Doing export: ${doexport}" + if (doexport) { + result = doExport(exportfolder, exportpathlist, destpart, build_variant) + if (result != 0) { + error "Failed to copy...." + } + } + } + else { + echo "Not building ${build_variant} variant of project: ${project}" + } + } catch (Exception e) { + echo "Exception: ${e.getMessage()}\nBuild failed - Waiting for a while" + sleep(time: 4, unit: 'SECONDS') + error "Build failed..." + } + } + } +} + +def doExportOnlyProject(String project, Boolean doexport, variants, String exportfolder, exportpathlist, String destpart) { + echo "Doing export only project: ${project} : ${doexport}" + if (doexport) { + if (!variants) { + result = doExport(exportfolder, exportpathlist, destpart) + if (result != 0) { + error "Failed to copy...." + } + } else { + for (build_variant in variants) { + if (toBuild.contains(build_variant)) { + result = doExport(exportfolder, exportpathlist, destpart, build_variant) + if (result != 0) { + error "Failed to copy...." + } + } + } + } + } +} + +// Build and export files +def doBuild(apps, ds5folder, ds5shellcommand, buildcommand, sourcefolder, variantstobuild, exportfolder = "${WORKSPACE}") { + toBuild = [] + if (variantstobuild) { + toBuildUntrimmed = variantstobuild.split(',') + toBuildUntrimmed.each { + toBuild.add(it.trim()) + } + } + // The lock is being used because it was being found that the doKillLeftovers was affecting other builds + lock(resource: "eclipsebuild_${env.NODE_NAME}") { + try { + timeout(time: 5, unit: 'MINUTES') { + doImportProjects(ds5folder, ds5shellcommand, buildcommand, sourcefolder) + } + for (appInfo in apps) { + def Boolean build + def Boolean doexport + (build, doexport, project, variants, exportpathlist, destpart) = appInfo + if (build) { + doBuildAndExportProject(ds5folder, ds5shellcommand, buildcommand, project, doexport, variants, exportfolder, exportpathlist, destpart) + } + else { + doExportOnlyProject(project, doexport, variants, exportfolder, exportpathlist, destpart) + } + } + } catch (Exception e) { + // doKillLeftovers() + error "Exception: ${e.getMessage()}\nBuild failed - Killing leftovers" + } + } +} + +return this; diff --git a/differences/file.groovy b/differences/file.groovy index ab4102f..ee1b8b3 100644 --- a/differences/file.groovy +++ b/differences/file.groovy @@ -1,15 +1,23 @@ def comparefiles(importedfile, currentfile, boolean ignorewhitespace = true) { + echo "Comparing file: ${importedfile} with: ${currentfile} option: ${ignorewhitespace}" + def wsparameter = "-w" + if (!ignorewhitespace) { + wsparameter = "" + } if (isUnix()) { - def wsparameter = "-w" - if (!ignorewhitespace) { - wsparameter = "" - } sh """ diff -c ${wsparameter} "${importedfile}" "${currentfile}" """ } else { - error "Windows not currently supporting file comparison" + // diffutils can be installed on windows with chocolatey + powershell """ + # echo Checking utilities exist + # where diff + # if errorlevel 1 EXIT /b 1 + + diff.exe -c ${wsparameter} "${importedfile}" "${currentfile}" + """ } } diff --git a/differences/json.groovy b/differences/json.groovy index 5ac37f2..dbf47b8 100644 --- a/differences/json.groovy +++ b/differences/json.groovy @@ -1,4 +1,5 @@ def comparefiles(importedjsonfile, currentjsonfile) { + echo "Comparing json file: ${importedjsonfile} with: ${currentjsonfile}" if (isUnix()) { sh """ which jq @@ -8,7 +9,42 @@ def comparefiles(importedjsonfile, currentjsonfile) { """ } else { - error "Windows not currently supporting json file comparison" + // Jq and diffutils can be installed on windows with chocolatey + powershell """ + # echo Checking utilities exist + # set + # echo %PATH% + try { + if (Get-Command jq) {} + } + catch { + echo "jq is unavailable" + exit \$false + } + try { + if (Get-Command diff) {} + } + catch { + echo "diff is unavailable" + exit \$false + } + + # echo Sorting json in files to compare + # jq -S sorts json output + jq -S . "${importedjsonfile}" > temp1.txt + if (\$lastexitcode -ge 1) { exit 1 } + jq -S . "${currentjsonfile}" > temp2.txt + if (\$lastexitcode -ge 1) { exit 1 } + + # echo Diffing sorted json files + diff.exe -c temp1.txt temp2.txt + \$lec = \$lastexitcode + + Remove-Item temp1.txt + Remove-Item temp2.txt + + if (\$lec -ge 1) { exit 1 } + """ } } diff --git a/documentation/doxygen_deploy.groovy b/documentation/doxygen_deploy.groovy new file mode 100644 index 0000000..6642256 --- /dev/null +++ b/documentation/doxygen_deploy.groovy @@ -0,0 +1,80 @@ +pipeline { + agent { label "${AGENT_LABEL}" } + stages { + stage('Initial setup') { + steps { + script { + meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this) + } + } + } + stage('Clean imports') { + steps { + script { + env.DOXYGEN = "doxygen" + cleanfolders = [ + DOXYGEN, + ] + cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy") + cleaner.clean(cleanfolders) + } + } + } + stage('Import doxygen artifacts') { + steps { + script { + importer = load("${autobuilder.commonscripts()}/import/importer.groovy") + def importoptions = importer.getNewImportOptions() + + importoptions.jenkinsjob(BUILD_JOB_WITH_DOXYGEN_ARTIFACTS, BUILD_JOB_WITH_DOXYGEN_ARTIFACTS_SELECTOR) + importoptions.setfilter(ARTIFACT_PATH_TO_DOXYGEN_ROOT + '/**') + doxygenmeta = importer.artifactimportfrombuildjob(meta, importoptions, DOXYGEN) + + productname = doxygenmeta.productinfo.productname + buildstampprefix = doxygenmeta.buildstampinfo.buildstampprefix + + echo "Doyxgen imported for product: ${productname} and build stamp prefix: ${buildstampprefix}" + } + } + } + stage('Copy doxygen to server') { + steps { + script { + doxygensource = "${DOXYGEN}/${ARTIFACT_PATH_TO_DOXYGEN_ROOT}" + pathonserver = "${ROOT_PATH_ON_SERVER.trim()}/${productname}/${buildstampprefix}" + echo "Copying from ${doxygensource} to ${pathonserver}" + if (isUnix()) { + sh """#!/bin/bash + rm -rfv "${pathonserver}" + if [ \$? -ne 0 ]; then exit 1; fi + + mkdir -pv "${pathonserver}" + if [ \$? -ne 0 ]; then exit 1; fi + + echo mv -v "${doxygensource}"/ "${pathonserver}" + mv -v "${doxygensource}"/ "${pathonserver}" + if [ \$? -ne 0 ]; then exit 1; fi + """ + } else { + error("This job does not run on Windows at the moment") + } + } + } + } + } + post { + always { + echo 'Post-build' + } + failure { + echo 'Failed build' + } + unstable { + echo 'Unstable build' + } + success { + echo 'Succeeded build' + } + } +} + diff --git a/packaging/debian.groovy b/packaging/debian.groovy index 2ef1ba8..c0a4dbb 100644 --- a/packaging/debian.groovy +++ b/packaging/debian.groovy @@ -17,8 +17,10 @@ class DebRootDefinition { String GIS_OPT_SCRIPTS_CONTROL String GIS_OPT_WWW String GIS_OPT_OTHER + String GIS_OPT_KERNEL String GIS_OPT_LOGIC String GIS_OPT_PRINTHEAD + String GIS_OPT_BOOT String USR_BIN String USR_LIB_ARCH @@ -26,7 +28,7 @@ class DebRootDefinition { String HTTP_DEV_DIV String LIB_SYSTEMD - DebRootDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp) { + DebRootDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp, String inpackagepathsuffix) { ROOTPATH = rootpath PACKAGE_PREFIX = packageprefix PACKAGE_FOLDER_NAME = packageprefix @@ -37,27 +39,29 @@ class DebRootDefinition { PACKAGE_SOURCE_FOLDER_NAME = "${ROOTPATH}/${PACKAGE_PREFIX}" DEBPATH = "${ROOTPATH}/${PACKAGE_FOLDER_NAME}" - ETC = "${DEBPATH}/etc" - GIS_OPT_BIN = "${DEBPATH}/opt/gis/bin" - GIS_OPT_LIB = "${DEBPATH}/opt/gis/lib" - GIS_OPT_SCRIPTS_APP = "${DEBPATH}/opt/gis/scripts/app" - GIS_OPT_SCRIPTS_EL = "${DEBPATH}/opt/gis/scripts/el" - GIS_OPT_SCRIPTS_CONTROL = "${DEBPATH}/opt/gis/scripts/control" - GIS_OPT_WWW = "${DEBPATH}/opt/gis/www" - GIS_OPT_OTHER = "${DEBPATH}/opt/gis/other" - GIS_OPT_LOGIC = "${DEBPATH}/opt/gis/logic" - GIS_OPT_PRINTHEAD = "${DEBPATH}/opt/gis/printhead" + ETC = "${DEBPATH}/etc" + inpackagepathsuffix + GIS_OPT_BIN = "${DEBPATH}/opt/gis/bin" + inpackagepathsuffix + GIS_OPT_LIB = "${DEBPATH}/opt/gis/lib" + inpackagepathsuffix + GIS_OPT_SCRIPTS_APP = "${DEBPATH}/opt/gis/scripts/app" + inpackagepathsuffix + GIS_OPT_SCRIPTS_EL = "${DEBPATH}/opt/gis/scripts/el" + inpackagepathsuffix + GIS_OPT_SCRIPTS_CONTROL = "${DEBPATH}/opt/gis/scripts/control" + inpackagepathsuffix + GIS_OPT_WWW = "${DEBPATH}/opt/gis/www" + inpackagepathsuffix + GIS_OPT_OTHER = "${DEBPATH}/opt/gis/other" + inpackagepathsuffix + GIS_OPT_KERNEL = "${DEBPATH}/opt/gis/kernel" + inpackagepathsuffix + GIS_OPT_LOGIC = "${DEBPATH}/opt/gis/logic" + inpackagepathsuffix + GIS_OPT_PRINTHEAD = "${DEBPATH}/opt/gis/printhead" + inpackagepathsuffix + GIS_OPT_BOOT = "${DEBPATH}/opt/gis/boot" + inpackagepathsuffix - USR_BIN = "${DEBPATH}/usr/bin" - USR_LIB_ARCH = "${DEBPATH}/usr/lib/arm-linux-gnueabihf" - LIB_FIRMWARE = "${DEBPATH}/lib/firmware" - HTTP_DEV_DIV = "${DEBPATH}/var/www/gis_dev" - LIB_SYSTEMD = "${DEBPATH}/lib/systemd" + USR_BIN = "${DEBPATH}/usr/bin" + inpackagepathsuffix + USR_LIB_ARCH = "${DEBPATH}/usr/lib/arm-linux-gnueabihf" + inpackagepathsuffix + LIB_FIRMWARE = "${DEBPATH}/lib/firmware" + inpackagepathsuffix + HTTP_DEV_DIV = "${DEBPATH}/var/www/gis_dev" + inpackagepathsuffix + LIB_SYSTEMD = "${DEBPATH}/lib/systemd" + inpackagepathsuffix } } -def DebRootDefinition debDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp) { - return new DebRootDefinition(rootpath, packagesourceroot, packageprefix, buildstamp) +def DebRootDefinition debDefinition(String rootpath, String packagesourceroot, String packageprefix, String buildstamp, String inpackagepathsuffix = '') { + return new DebRootDefinition(rootpath, packagesourceroot, packageprefix, buildstamp, inpackagepathsuffix) } def buildPackage(String packageout, String uniquepackageout, DebRootDefinition packagedefs, String password) { @@ -70,7 +74,6 @@ def buildPackage(String packageout, String uniquepackageout, DebRootDefinition p cp -v -r "${packagedefs.PACKAGE_SOURCE_ROOT}/${packagedefs.PACKAGE_SOURCE_FOLDER_NAME}"/* "${packagedefs.DEBPATH}" - sudo chmod -v -R 755 "${packagedefs.DEBPATH}" sudo chown -v -R root: "${packagedefs.DEBPATH}" mkdir -v -p "${packageout}" diff --git a/publish/package.groovy b/publish/package.groovy index 2d5fdcc..3bd9565 100644 --- a/publish/package.groovy +++ b/publish/package.groovy @@ -115,6 +115,19 @@ pipeline { FULL_SNAPSHOT_NAME = "${REPO_NAME}_${SNAPSHOT_NAME}" PACKAGE_VERSION_PREFIX = packagemeta.buildstampinfo.buildstampprefix echo "Full Snapshot name is ${FULL_SNAPSHOT_NAME} containing packages of versions beginning with: ${PACKAGE_VERSION_PREFIX}" + // Convert prefix to regular expression + PACKAGE_VERSION_PREFIX_SPLIT = PACKAGE_VERSION_PREFIX.split("[.]") + PACKAGE_VERSION_REGEX = '' + i = 0 + while(true) { + if (i == PACKAGE_VERSION_PREFIX_SPLIT.size() - 1) { + PACKAGE_VERSION_REGEX += PACKAGE_VERSION_PREFIX_SPLIT[i] + break; + } + PACKAGE_VERSION_REGEX += PACKAGE_VERSION_PREFIX_SPLIT[i] + PACKAGE_VERSION_REGEX += '\\.' + i++ + } sh """#!/bin/bash -v # This errors if the snapshot exists already; Ignore it aptly snapshot -config="${APTLY_CONFIG_FILE}" drop "${FULL_SNAPSHOT_NAME}" @@ -122,7 +135,7 @@ pipeline { aptly snapshot -config="${APTLY_CONFIG_FILE}" create "All_${FULL_SNAPSHOT_NAME}" from repo "${REPO_NAME}" if [ \$? -ne 0 ]; then exit 1; fi - aptly snapshot filter -config="/home/repos/gis-aptly-config/gis.conf" "All_${FULL_SNAPSHOT_NAME}" "${FULL_SNAPSHOT_NAME}" 'Version (~ .*${PACKAGE_VERSION_PREFIX}.*)' + aptly snapshot filter -config="/home/repos/gis-aptly-config/gis.conf" "All_${FULL_SNAPSHOT_NAME}" "${FULL_SNAPSHOT_NAME}" 'Version (~ .*${PACKAGE_VERSION_REGEX}.*)' if [ \$? -ne 0 ]; then exit 1; fi aptly snapshot -config="${APTLY_CONFIG_FILE}" -with-packages show "${FULL_SNAPSHOT_NAME}" if [ \$? -ne 0 ]; then exit 1; fi diff --git a/publish/promptingpublish.groovy b/publish/promptingpublish.groovy index 9f2d7dc..21de708 100644 --- a/publish/promptingpublish.groovy +++ b/publish/promptingpublish.groovy @@ -62,14 +62,15 @@ pipeline { echo("Showing filtered releases") for (release in allreleases) { if (!release.toLowerCase().startsWith("superceded") && + !release.toLowerCase().startsWith("superseded") && !release.toLowerCase().startsWith("erroneous") && !release.toLowerCase().startsWith("faulty") && !release.toLowerCase().startsWith("ignore") && !release.toLowerCase().startsWith("inmainline")) { - //echo("Showing release: ${release}") + echo("Showing release: ${release}") releases.add(release) } else { - //echo("Not showing release: ${release}") + echo("Not showing release: ${release}") } } } diff --git a/release/do.groovy b/release/do.groovy index 3221d25..649e279 100644 --- a/release/do.groovy +++ b/release/do.groovy @@ -1,3 +1,5 @@ +gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy") + markunstable = false unstablereason = "" @@ -373,7 +375,8 @@ def gitrelease(buildmeta, previousreleasemeta, String releaserepo, String source def releasecomponent(toplevelbuildmeta, buildinfo, String otherreleasetags, String dryrunpush) { def buildmeta = buildinfo.meta - def String uniquefolder = "${buildmeta.productinfo.productname}_${buildmeta.productinfo.subcomponentname}" + def uriconverted = gh.uniquereporootname(buildmeta.gitinfo.remoteurl) + def String uniquefolder = "${buildmeta.productinfo.productname}_${buildmeta.productinfo.subcomponentname}_${uriconverted}" def String uniquefolderforrepo = "${releaserepofolder}/${uniquefolder}" def String uniquefoldertemp = "${tempfolder}/${uniquefolder}" def String uniquefolderforsourcerepo = "${sourcerepofolder}/${uniquefolder}" @@ -417,7 +420,14 @@ def releasehierarchy(buildmeta, String maxdepth, String otherreleasetags, String if (DO_INTEGRITY_CHECK == "true") { if (componentReleaseInfo.size() != componentReleaseInfoVersionUnique.size()) { - error "There are 2 or more versions of the same component being used in this hierarchy: Is this correct?" + error "There are 2 or more versions of the same component being used in this hierarchy: Is this correct? (If you ignore this issue, you will get an error much later because the system cannot tag 2 different commits of the associated source code with the same label)" + } + } + + for (key in componentReleaseInfo.keySet()) { + def buildinfo = componentReleaseInfo[key] + if (!buildinfo.jenkinsbuildinfo.isFullBuild()) { + error "The subcomponent: ${buildinfo.componentidentifier()} is not a full build (Some artifacts are missing)" } } diff --git a/staticanalysis/cpd.groovy b/staticanalysis/cpd.groovy index 2bd12d9..6f3a33f 100644 --- a/staticanalysis/cpd.groovy +++ b/staticanalysis/cpd.groovy @@ -1,5 +1,5 @@ pipeline { - agent { label "${AGENT_LABEL}" } + agent { label AGENT_LABEL } stages { stage('Initial setup') { steps { @@ -53,7 +53,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}" + } } } } @@ -81,20 +84,29 @@ pipeline { steps { script { def PPDFOLDER = "${STATICANALYSIS}/ppd" - dir(PPDFOLDER) { - 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 - """ - } else { - bat """ - set PMD_JAVA_OPTS=-Xmx2048m - "${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml --failOnViolation false > cpd.xml - """ + 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 += '"' + } + if (isUnix()) { + sh """#!/bin/bash + set -ev + + 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" + """ + } 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'), diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index f5b2ebd..50f4025 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -12,7 +12,7 @@ def boolean isShallowClonedRepo(String gitrootpath) { isshallowclone = sh(returnStdout: true, script: "git rev-parse --is-shallow-repository").trim().toBoolean() } else { - isshallowclone = bat(returnStdout: true, script: "@git rev-parse --is-shallow-repository").trim().toBoolean() + isshallowclone = powershell(returnStdout: true, script: "git rev-parse --is-shallow-repository").trim().toBoolean() } echo "Repo at ${gitrootpath} is shallow cloned: ${isshallowclone}" } @@ -89,9 +89,9 @@ def String checkouttoreporoot(String gitURL) { if [ \$? -ne 0 ]; then exit 1; fi """ } else { - bat """ + powershell """ git status - if errorlevel 1 EXIT /b 1 + if (\$lastexitcode -ge 1) { exit 1 } """ } } @@ -109,9 +109,9 @@ def checkgitlfsinstall() { """ } else { - bat """ + powershell """ git lfs install - if errorlevel 1 EXIT /b 1 + if (\$lastexitcode -ge 1) { exit 1 } """ } } @@ -185,6 +185,7 @@ def showsparseitemlist(ArrayList sparseitemlist = new ArrayList( } def docheckout(String gitURL, String revision, int cloneDepth, String reporootpath, boolean shallowClone, String targetDir, sparseitemlist) { + echo "Git: Checking out: URL: ${gitURL} Revision: ${revision} to: ${targetDir}" checkout([ $class: 'GitSCM', userRemoteConfigs: [ @@ -195,8 +196,8 @@ def docheckout(String gitURL, String revision, int cloneDepth, String reporootpa ], doGenerateSubmoduleConfigurations: false, extensions: [ - [$class: 'GitLFSPull'], - [$class: 'CleanBeforeCheckout'], + [$class: 'GitLFSPull',timeout: 25], + [$class: 'CleanBeforeCheckout',timeout: 20], [$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120], [$class: 'CheckoutOption', timeout: 120], [$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir], @@ -221,7 +222,7 @@ def gitinit(String targetDir, String reporootpath) { git init "${targetDir}" """ } else { - bat """ + powershell """ git init "${targetDir}" """ } @@ -245,7 +246,7 @@ def setlfsfetchinclude(String targetDir, ArrayList sparseitemlist) { git config lfs.fetchinclude "${sparseitemliststring}" """ } else { - bat """ + powershell """ git config lfs.fetchinclude "${sparseitemliststring}" """ } @@ -263,10 +264,10 @@ def gitsparserestore(String targetDir) { git reset --hard > /dev/null """ } else { - bat """ - git rm -rf . 2> nul - git clean -fxd 2> nul - git reset --hard 2> nul + powershell """ + git rm -rf . > \$null + git clean -fxd > \$null + git reset --hard > \$null """ } } @@ -311,8 +312,8 @@ def checkRepoExists(String gitURL) { returnStatus: true ) } else { - result = bat( script: """ - @git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY + result = powershell( script: """ + git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY """, returnStatus: true ) diff --git a/versionnumbering/do.groovy b/versionnumbering/do.groovy index 666aee3..208a60f 100644 --- a/versionnumbering/do.groovy +++ b/versionnumbering/do.groovy @@ -4,17 +4,17 @@ def stamp(convertdetails) { def filetoconvert = convertdetail[0] def pattern = convertdetail[1] def replacement = convertdetail[2] - //echo "Converting any instances of pattern: ${pattern} with replacement: ${replacement} in file: ${filetoconvert}" + echo "Converting any instances of pattern: ${pattern} with replacement: ${replacement} in file: ${filetoconvert}" def stampscript = "${autobuilder.commonscripts()}/versionstamping/versionstamper.py" - //echo "Using python: ${PYTHON} and script: ${stampscript}" + echo "Using python: ${PYTHON} and script: ${stampscript}" if (isUnix()) { sh """ "${PYTHON}" -u "${stampscript}" -f "${filetoconvert}" -p "${pattern}" -s "${replacement}" """ } else { - bat """ - "${PYTHON}" -u "${stampscript}" -f "${filetoconvert}" -p "${pattern}" -s "${replacement}" + powershell """ + & "${PYTHON}" -u "${stampscript}" -f "${filetoconvert}" -p "${pattern}" -s "${replacement}" """ } } diff --git a/versionnumbering/generate.groovy b/versionnumbering/generate.groovy index 71d7bf6..405b7be 100644 --- a/versionnumbering/generate.groovy +++ b/versionnumbering/generate.groovy @@ -28,7 +28,7 @@ def getGitRevision(String gitrootpath, int basebuildnumber) { changecount = sh(returnStdout: true, script: "git rev-list HEAD --count").trim().toInteger() } else { - changecount = bat(returnStdout: true, script: "@git rev-list HEAD --count").trim().toInteger() + changecount = powershell(returnStdout: true, script: "git rev-list HEAD --count").trim().toInteger() } echo "Change count: ${changecount}" def int mvnp1 = maxversionnumber() + 1 @@ -39,21 +39,21 @@ def getGitRevision(String gitrootpath, int basebuildnumber) { gitrevision = sh(returnStdout: true, script: "git rev-parse HEAD").trim() } else { - gitrevision = bat(returnStdout: true, script: "@git rev-parse HEAD").trim() + gitrevision = powershell(returnStdout: true, script: "git rev-parse HEAD").trim() } echo "Revision: ${gitrevision}" if (isUnix()) { remoteinfo = sh(returnStdout: true, script: "git remote show origin").trim() } else { - remoteinfo = bat(returnStdout: true, script: "@git remote show origin").trim() + remoteinfo = powershell(returnStdout: true, script: "git remote show origin").trim() } echo "Remote info: ${remoteinfo}" if (isUnix()) { remoteurl = sh(returnStdout: true, script: "git config --get remote.origin.url").trim() } else { - remoteurl = bat(returnStdout: true, script: "@git config --get remote.origin.url").trim() + remoteurl = powershell(returnStdout: true, script: "git config --get remote.origin.url").trim() } echo "Remote URL: ${remoteurl}" } diff --git a/versionstamping/versionstamper.py b/versionstamping/versionstamper.py index 441ad06..9243aa4 100644 --- a/versionstamping/versionstamper.py +++ b/versionstamping/versionstamper.py @@ -17,7 +17,7 @@ def main(argv): pattern = args.pattern substitute = args.substitute - print("Converting incidences of {0} with {1} in file: {2}\n".format(pattern, substitute, filetoconvert)) + print("Converting instances of {0} with {1} in file: {2}\n".format(pattern, substitute, filetoconvert)) with open(filetoconvert,'r') as c: fileread = c.read()