Skip to content
Snippets Groups Projects
helper.groovy 20.74 KiB
/***********************************************************************************************************************

  steps is used from buildTestDeploy

***********************************************************************************************************************/

/**********************************************************************************************************************/

// helper function, recursively gather a deep list of dependencies
def gatherDependenciesDeep(ArrayList<String> dependencyList) {
  script {
    def deepList = dependencyList
    dependencyList.each {
      if(it != "") {
        def dependencyProjectName = it
        if(env.JOB_TYPE != "") {
          def (dependencyFolder, dependencyProject) = dependencyProjectName.split('/')
          dependencyProjectName = "${dependencyFolder}/${env.JOB_TYPE}/${dependencyProject}/master"
        }
        copyArtifacts filter: "dependencyList.txt", fingerprintArtifacts: true, projectName: dependencyProjectName, selector: lastSuccessful(), target: "artefacts"
        myFile = readFile(env.WORKSPACE+"/artefacts/dependencyList.txt")
        deepList.addAll(gatherDependenciesDeep(new ArrayList<String>(Arrays.asList(myFile.split("\n")))))
      }
    }
    return deepList.unique()
  }
}

/**********************************************************************************************************************/

def doBuildTestDeploy(ArrayList<String> dependencyList, String label, String buildType, String gitUrl) {

  // prepare source directory and dependencies
  doPrepare(true, gitUrl)
  doDependencyArtefacts(dependencyList, label, buildType)

  // add inactivity timeout of 30 minutes (build will be interrupted if 30 minutes no log output has been produced)
  timeout(activity: true, time: 30) {
 
    // start build and tests, then generate artefact
    doBuild(label, buildType)
    if(buildType != "asan" && buildType != "tsan" && !env.DISABLE_TEST) {
      // tests for asan and tsan are run in the analysis jobs
      doTest(label, buildType)
    }

    // Run cppcheck only for focal-debug
    //if((!env.DISABLE_CPPCHECK || env.DISABLE_CPPCHECK == '') && buildType == "Debug") {
    //    doCppcheck(label, buildType)
    //}

    doInstall(label, buildType)

  }
}

/**********************************************************************************************************************/

def doAnalysis(String label, String buildType) {
  if(buildType == "Debug") {
    doPrepare(false)
    doBuilddirArtefact(label, buildType)

    // Add inactivity timeout of 60 minutes (build will be interrupted if 60 minutes no log output has been produced)
    timeout(activity: true, time: 60) {

      // Coverage report only works well in Debug mode, since optimisation might lead to underestimated coverage
      doCoverage(label, buildType)
      
      // Run valgrind only in Debug mode, since Release mode often leads to no-longer-matching suppressions