From 22a8885502607cbe236cfb6994a11b43729c2e16 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 28 Apr 2021 12:10:29 -0700 Subject: [PATCH 1/3] Fixing test metrics to run on test failures --- scripts/build/Jenkins/Jenkinsfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index bb9bd4ff48..07a4023674 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -505,6 +505,8 @@ try { } withEnv(GetEnvStringList(envVars)) { try { + def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY + def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION def build_job_name = build_job.key CreateSetupStage(pipelineConfig, repositoryName, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() @@ -517,12 +519,6 @@ try { } else { CreateBuildStage(pipelineConfig, platform.key, build_job.key, envVars).call() } - - if (env.MARS_REPO && platform.value.build_types[build_job_name].PARAMETERS.containsKey('TEST_METRICS') && platform.value.build_types[build_job_name].PARAMETERS.TEST_METRICS == 'True') { - def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY - def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION - CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() - } } catch(Exception e) { // https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Result.java @@ -537,6 +533,14 @@ try { } } finally { + try { + if (env.MARS_REPO && platform.value.build_types[build_job_name].PARAMETERS.containsKey('TEST_METRICS') && platform.value.build_types[build_job_name].PARAMETERS.TEST_METRICS == 'True') { + CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() + } + } + catch(Exception e) { + echo "Test metrics failed due to: ${e}" + } CreateTeardownStage(envVars).call() } } From c554a7b17eeedf339c956c9cbd5bc20935df38a4 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 28 Apr 2021 14:22:31 -0700 Subject: [PATCH 2/3] Moved variable assigments and removed try/catch block for test metrics --- scripts/build/Jenkins/Jenkinsfile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 07a4023674..58d5baa2a4 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -505,8 +505,6 @@ try { } withEnv(GetEnvStringList(envVars)) { try { - def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY - def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION def build_job_name = build_job.key CreateSetupStage(pipelineConfig, repositoryName, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() @@ -533,13 +531,10 @@ try { } } finally { - try { - if (env.MARS_REPO && platform.value.build_types[build_job_name].PARAMETERS.containsKey('TEST_METRICS') && platform.value.build_types[build_job_name].PARAMETERS.TEST_METRICS == 'True') { - CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() - } - } - catch(Exception e) { - echo "Test metrics failed due to: ${e}" + if (env.MARS_REPO && platform.value.build_types[build_job_name].PARAMETERS.containsKey('TEST_METRICS') && platform.value.build_types[build_job_name].PARAMETERS.TEST_METRICS == 'True') { + def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY + def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION + CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() } CreateTeardownStage(envVars).call() } From 1b8c62f2941623b4da9f0274e801fb78000179dd Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 28 Apr 2021 23:04:32 -0700 Subject: [PATCH 3/3] Fixed out of scope variable --- scripts/build/Jenkins/Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 58d5baa2a4..98f31eddea 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -504,9 +504,8 @@ try { envVars['IS_UNIX'] = 1 } withEnv(GetEnvStringList(envVars)) { + def build_job_name = build_job.key try { - def build_job_name = build_job.key - CreateSetupStage(pipelineConfig, repositoryName, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() if(build_job.value.steps) { //this is a pipe with many steps so create all the build stages